Show theme names in theme switcher

This commit is contained in:
Ryan Hughes
2026-05-11 15:40:19 -04:00
parent f6bd69bc0f
commit b89079ae5c
3 changed files with 40 additions and 10 deletions
+9 -4
View File
@@ -1,13 +1,14 @@
#!/bin/bash #!/bin/bash
# omarchy:summary=Open a generic image selector menu # omarchy:summary=Open a generic image selector menu
# omarchy:args=[--selected <image>] [--colors-file <path>] [--print-name] [--cache-only] <image-dir>... # omarchy:args=[--selected <image>] [--colors-file <path>] [--print-name] [--show-labels] [--cache-only] <image-dir>...
OMARCHY_PATH=${OMARCHY_PATH:-$HOME/.local/share/omarchy} OMARCHY_PATH=${OMARCHY_PATH:-$HOME/.local/share/omarchy}
selected_image="" selected_image=""
colors_file="" colors_file=""
print_name=false print_name=false
show_labels=false
cache_only=false cache_only=false
image_dirs=() image_dirs=()
@@ -25,12 +26,16 @@ while [[ $# -gt 0 ]]; do
print_name=true print_name=true
shift shift
;; ;;
--show-labels)
show_labels=true
shift
;;
--cache-only) --cache-only)
cache_only=true cache_only=true
shift shift
;; ;;
--help|-h) --help|-h)
echo "Usage: omarchy-menu-images [--selected <image>] [--colors-file <path>] [--print-name] [--cache-only] <image-dir>..." echo "Usage: omarchy-menu-images [--selected <image>] [--colors-file <path>] [--print-name] [--show-labels] [--cache-only] <image-dir>..."
exit 0 exit 0
;; ;;
*) *)
@@ -41,7 +46,7 @@ while [[ $# -gt 0 ]]; do
done done
if (( ${#image_dirs[@]} == 0 )); then if (( ${#image_dirs[@]} == 0 )); then
echo "Usage: omarchy-menu-images [--selected <image>] [--colors-file <path>] [--print-name] [--cache-only] <image-dir>..." >&2 echo "Usage: omarchy-menu-images [--selected <image>] [--colors-file <path>] [--print-name] [--show-labels] [--cache-only] <image-dir>..." >&2
exit 1 exit 1
fi fi
@@ -173,7 +178,7 @@ if [[ ! -S $socket_path ]]; then
exit 1 exit 1
fi 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" socat -u - "UNIX-CONNECT:$socket_path"
while [[ ! -e $done_file ]]; do while [[ ! -e $done_file ]]; do
+1
View File
@@ -75,5 +75,6 @@ for extension in png jpg jpeg webp; do
done done
exec omarchy-menu-images \ exec omarchy-menu-images \
--print-name \ --print-name \
--show-labels \
--selected "$selected_preview" \ --selected "$selected_preview" \
"$preview_dir" "$preview_dir"
+30 -6
View File
@@ -16,6 +16,7 @@ ShellRoot {
property int selectedIndex: 0 property int selectedIndex: 0
property bool imagesLoaded: false property bool imagesLoaded: false
property bool opened: false property bool opened: false
property bool showLabels: false
property string doneFile: "" property string doneFile: ""
property string socketPath: (Quickshell.env("XDG_RUNTIME_DIR") || ("/run/user/" + Quickshell.env("UID"))) + "/omarchy-image-selector.sock" property string socketPath: (Quickshell.env("XDG_RUNTIME_DIR") || ("/run/user/" + Quickshell.env("UID"))) + "/omarchy-image-selector.sock"
property color accent: "#798186" property color accent: "#798186"
@@ -44,6 +45,14 @@ ShellRoot {
return imageModel.get(selectedIndex).filePath 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) { function select(index) {
if (imageModel.count === 0) return if (imageModel.count === 0) return
if (index < 0) index = imageModel.count - 1 if (index < 0) index = imageModel.count - 1
@@ -83,12 +92,13 @@ ShellRoot {
list.forceActiveFocus() list.forceActiveFocus()
} }
function openSelector(nextImageDirs, nextImageRows, nextSelectedImage, nextSelectionFile, nextDoneFile, nextColorsFile, nextColorsRaw) { function openSelector(nextImageDirs, nextImageRows, nextSelectedImage, nextSelectionFile, nextDoneFile, nextColorsFile, nextColorsRaw, nextShowLabels) {
imageDirs = nextImageDirs imageDirs = nextImageDirs
imageRows = nextImageRows imageRows = nextImageRows
selectedImage = nextSelectedImage selectedImage = nextSelectedImage
selectionFile = nextSelectionFile selectionFile = nextSelectionFile
doneFile = nextDoneFile doneFile = nextDoneFile
showLabels = nextShowLabels === true || nextShowLabels === "true"
colorsFile = nextColorsFile || (Quickshell.env("HOME") + "/.config/omarchy/current/theme/background-switcher-colors.json") colorsFile = nextColorsFile || (Quickshell.env("HOME") + "/.config/omarchy/current/theme/background-switcher-colors.json")
if (nextColorsRaw) if (nextColorsRaw)
loadColors(nextColorsRaw) loadColors(nextColorsRaw)
@@ -150,14 +160,14 @@ ShellRoot {
Component.onCompleted: { Component.onCompleted: {
if (selectionFile) 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 { IpcHandler {
target: "image-selector" target: "image-selector"
function open(imageDirs: string, imageRows: string, selectedImage: string, selectionFile: string, doneFile: string, colorsFile: string): void { 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 { parser: SplitParser {
onRead: function(message) { onRead: function(message) {
var fields = message.split("\t") 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 clientSocket.connected = false
} }
} }
@@ -226,7 +236,7 @@ ShellRoot {
Item { Item {
id: card id: card
width: Math.min(parent.width - 80, root.expandedWidth + 13 * (root.sliceWidth + root.sliceSpacing) + 40) 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 anchors.centerIn: parent
MouseArea { anchors.fill: parent; onClicked: {} } MouseArea { anchors.fill: parent; onClicked: {} }
@@ -236,7 +246,7 @@ ShellRoot {
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 30 anchors.topMargin: 30
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: 30 anchors.bottomMargin: root.showLabels ? 74 : 30
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: root.expandedWidth + 13 * (root.sliceWidth + root.sliceSpacing) width: root.expandedWidth + 13 * (root.sliceWidth + root.sliceSpacing)
orientation: ListView.Horizontal 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
}
} }
} }
} }