From f6bd69bc0f0261e9397443d0ae84240921023346 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 11 May 2026 18:20:27 +0200 Subject: [PATCH] Fix color sync --- bin/omarchy-menu-images | 10 +++++++++- default/quickshell/background-switcher.qml | 10 ++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/bin/omarchy-menu-images b/bin/omarchy-menu-images index e5909560..1d702079 100755 --- a/bin/omarchy-menu-images +++ b/bin/omarchy-menu-images @@ -137,6 +137,14 @@ fi rows_payload=${rows//$'\t'/$'\f'} rows_payload=${rows_payload//$'\n'/$'\v'} +colors_file=${colors_file:-$HOME/.config/omarchy/current/theme/background-switcher-colors.json} +colors_payload="" + +if [[ -f $colors_file ]]; then + colors_payload=$(<"$colors_file") + colors_payload=${colors_payload//$'\t'/$'\f'} + colors_payload=${colors_payload//$'\n'/$'\v'} +fi if [[ $cache_only == true ]]; then exit 0 @@ -165,7 +173,7 @@ if [[ ! -S $socket_path ]]; then exit 1 fi -printf '%s\t%s\t%s\t%s\t%s\n' "$rows_payload" "$selected_list_image" "$selection_file" "$done_file" "$colors_file" | +printf '%s\t%s\t%s\t%s\t%s\n' "$rows_payload" "$selected_list_image" "$selection_file" "$done_file" "$colors_payload" | socat -u - "UNIX-CONNECT:$socket_path" while [[ ! -e $done_file ]]; do diff --git a/default/quickshell/background-switcher.qml b/default/quickshell/background-switcher.qml index aeea282f..83c2b7b8 100644 --- a/default/quickshell/background-switcher.qml +++ b/default/quickshell/background-switcher.qml @@ -83,13 +83,15 @@ ShellRoot { list.forceActiveFocus() } - function openSelector(nextImageDirs, nextImageRows, nextSelectedImage, nextSelectionFile, nextDoneFile, nextColorsFile) { + function openSelector(nextImageDirs, nextImageRows, nextSelectedImage, nextSelectionFile, nextDoneFile, nextColorsFile, nextColorsRaw) { imageDirs = nextImageDirs imageRows = nextImageRows selectedImage = nextSelectedImage selectionFile = nextSelectionFile doneFile = nextDoneFile colorsFile = nextColorsFile || (Quickshell.env("HOME") + "/.config/omarchy/current/theme/background-switcher-colors.json") + if (nextColorsRaw) + loadColors(nextColorsRaw) imageModel.clear() selectedIndex = 0 list.currentIndex = 0 @@ -148,14 +150,14 @@ ShellRoot { Component.onCompleted: { if (selectionFile) - openSelector(imageDirs, "", selectedImage, selectionFile, Quickshell.env("OMARCHY_IMAGE_SELECTOR_DONE_FILE"), colorsFile) + openSelector(imageDirs, "", selectedImage, selectionFile, Quickshell.env("OMARCHY_IMAGE_SELECTOR_DONE_FILE"), colorsFile, "") } IpcHandler { target: "image-selector" function open(imageDirs: string, imageRows: string, selectedImage: string, selectionFile: string, doneFile: string, colorsFile: string): void { - root.openSelector(imageDirs, imageRows, selectedImage, selectionFile, doneFile, colorsFile) + root.openSelector(imageDirs, imageRows, selectedImage, selectionFile, doneFile, colorsFile, "") } } @@ -168,7 +170,7 @@ ShellRoot { parser: SplitParser { onRead: function(message) { var fields = message.split("\t") - root.openSelector("", root.decodeField(fields[0]), fields[1] || "", fields[2] || "", fields[3] || "", fields[4] || "") + root.openSelector("", root.decodeField(fields[0]), fields[1] || "", fields[2] || "", fields[3] || "", "", root.decodeField(fields[4])) clientSocket.connected = false } }