diff --git a/bin/omarchy-menu-images b/bin/omarchy-menu-images index 1d702079..bf0c535d 100755 --- a/bin/omarchy-menu-images +++ b/bin/omarchy-menu-images @@ -1,13 +1,14 @@ #!/bin/bash # omarchy:summary=Open a generic image selector menu -# omarchy:args=[--selected ] [--colors-file ] [--print-name] [--cache-only] ... +# omarchy:args=[--selected ] [--colors-file ] [--print-name] [--show-labels] [--cache-only] ... OMARCHY_PATH=${OMARCHY_PATH:-$HOME/.local/share/omarchy} selected_image="" colors_file="" print_name=false +show_labels=false cache_only=false image_dirs=() @@ -25,12 +26,16 @@ while [[ $# -gt 0 ]]; do print_name=true shift ;; + --show-labels) + show_labels=true + shift + ;; --cache-only) cache_only=true shift ;; --help|-h) - echo "Usage: omarchy-menu-images [--selected ] [--colors-file ] [--print-name] [--cache-only] ..." + echo "Usage: omarchy-menu-images [--selected ] [--colors-file ] [--print-name] [--show-labels] [--cache-only] ..." exit 0 ;; *) @@ -41,7 +46,7 @@ while [[ $# -gt 0 ]]; do done if (( ${#image_dirs[@]} == 0 )); then - echo "Usage: omarchy-menu-images [--selected ] [--colors-file ] [--print-name] [--cache-only] ..." >&2 + echo "Usage: omarchy-menu-images [--selected ] [--colors-file ] [--print-name] [--show-labels] [--cache-only] ..." >&2 exit 1 fi @@ -173,7 +178,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_payload" | +printf '%s\t%s\t%s\t%s\t%s\t%s\n' "$rows_payload" "$selected_list_image" "$selection_file" "$done_file" "$colors_payload" "$show_labels" | socat -u - "UNIX-CONNECT:$socket_path" while [[ ! -e $done_file ]]; do diff --git a/bin/omarchy-theme-switcher b/bin/omarchy-theme-switcher index 89480c96..a21ed4aa 100755 --- a/bin/omarchy-theme-switcher +++ b/bin/omarchy-theme-switcher @@ -75,5 +75,6 @@ for extension in png jpg jpeg webp; do done exec omarchy-menu-images \ --print-name \ + --show-labels \ --selected "$selected_preview" \ "$preview_dir" diff --git a/default/quickshell/background-switcher.qml b/default/quickshell/background-switcher.qml index 83c2b7b8..5889345e 100644 --- a/default/quickshell/background-switcher.qml +++ b/default/quickshell/background-switcher.qml @@ -16,6 +16,7 @@ ShellRoot { property int selectedIndex: 0 property bool imagesLoaded: false property bool opened: false + property bool showLabels: false property string doneFile: "" property string socketPath: (Quickshell.env("XDG_RUNTIME_DIR") || ("/run/user/" + Quickshell.env("UID"))) + "/omarchy-image-selector.sock" property color accent: "#798186" @@ -44,6 +45,14 @@ ShellRoot { return imageModel.get(selectedIndex).filePath } + function currentLabel() { + var path = currentPath() + if (!path) return "" + + var name = path.split("/").pop().replace(/\.[^/.]+$/, "") + return name.replace(/[-_]+/g, " ").replace(/\b\w/g, function(match) { return match.toUpperCase() }) + } + function select(index) { if (imageModel.count === 0) return if (index < 0) index = imageModel.count - 1 @@ -83,12 +92,13 @@ ShellRoot { list.forceActiveFocus() } - function openSelector(nextImageDirs, nextImageRows, nextSelectedImage, nextSelectionFile, nextDoneFile, nextColorsFile, nextColorsRaw) { + function openSelector(nextImageDirs, nextImageRows, nextSelectedImage, nextSelectionFile, nextDoneFile, nextColorsFile, nextColorsRaw, nextShowLabels) { imageDirs = nextImageDirs imageRows = nextImageRows selectedImage = nextSelectedImage selectionFile = nextSelectionFile doneFile = nextDoneFile + showLabels = nextShowLabels === true || nextShowLabels === "true" colorsFile = nextColorsFile || (Quickshell.env("HOME") + "/.config/omarchy/current/theme/background-switcher-colors.json") if (nextColorsRaw) loadColors(nextColorsRaw) @@ -150,14 +160,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, "", false) } 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, "", false) } } @@ -170,7 +180,7 @@ ShellRoot { parser: SplitParser { onRead: function(message) { var fields = message.split("\t") - root.openSelector("", root.decodeField(fields[0]), fields[1] || "", fields[2] || "", fields[3] || "", "", root.decodeField(fields[4])) + root.openSelector("", root.decodeField(fields[0]), fields[1] || "", fields[2] || "", fields[3] || "", "", root.decodeField(fields[4]), fields[5] || "false") clientSocket.connected = false } } @@ -226,7 +236,7 @@ ShellRoot { Item { id: card width: Math.min(parent.width - 80, root.expandedWidth + 13 * (root.sliceWidth + root.sliceSpacing) + 40) - height: root.sliceHeight + 60 + height: root.sliceHeight + (root.showLabels ? 104 : 60) anchors.centerIn: parent MouseArea { anchors.fill: parent; onClicked: {} } @@ -236,7 +246,7 @@ ShellRoot { anchors.top: parent.top anchors.topMargin: 30 anchors.bottom: parent.bottom - anchors.bottomMargin: 30 + anchors.bottomMargin: root.showLabels ? 74 : 30 anchors.horizontalCenter: parent.horizontalCenter width: root.expandedWidth + 13 * (root.sliceWidth + root.sliceSpacing) orientation: ListView.Horizontal @@ -395,6 +405,20 @@ ShellRoot { } } } + + Text { + visible: root.showLabels + anchors.top: list.bottom + anchors.topMargin: 16 + anchors.horizontalCenter: list.horizontalCenter + width: root.expandedWidth + text: root.currentLabel() + color: root.foreground + font.pixelSize: 24 + font.weight: Font.DemiBold + horizontalAlignment: Text.AlignHCenter + elide: Text.ElideRight + } } } }