diff --git a/config/omarchy/shell.json b/config/omarchy/shell.json index a1d73f13..d00273c8 100644 --- a/config/omarchy/shell.json +++ b/config/omarchy/shell.json @@ -18,6 +18,9 @@ } ], "center": [ + { + "id": "omarchy.indicators" + }, { "id": "omarchy.clock", "format": "dddd HH:mm", diff --git a/migrations/1784989000.sh b/migrations/1784989000.sh new file mode 100644 index 00000000..a0fc8760 --- /dev/null +++ b/migrations/1784989000.sh @@ -0,0 +1,39 @@ +echo "Move the bar indicators to the left of the clock" + +config_file="$HOME/.config/omarchy/shell.json" + +if [[ -s $config_file ]] && omarchy-cmd-present jq; then + tmp=$(mktemp) + jq ' + def entry_id: + if type == "string" then + . + elif type == "object" then + (.id // "") + else + "" + end; + + def entry_index($id): + [range(0; length) as $i | select((.[$i] | entry_id) == $id) | $i][0]; + + def place_indicators_before_clock: + if type != "array" then + . + else + (entry_index("omarchy.clock")) as $clock_index | + (entry_index("omarchy.indicators")) as $indicators_index | + if $clock_index == null or $indicators_index == null or $indicators_index < $clock_index then + . + else + . as $entries | + ($entries[$indicators_index]) as $indicators_entry | + ($entries | del(.[$indicators_index])) as $without_indicators | + ($without_indicators | entry_index("omarchy.clock")) as $new_clock_index | + $without_indicators[0:$new_clock_index] + [$indicators_entry] + $without_indicators[$new_clock_index:] + end + end; + + .bar.layout.center |= place_indicators_before_clock + ' "$config_file" >"$tmp" && mv "$tmp" "$config_file" || rm -f "$tmp" +fi diff --git a/shell/plugins/bar/widgets/Indicators.manifest.json b/shell/plugins/bar/widgets/Indicators.manifest.json index 1fe669e3..2a52f979 100644 --- a/shell/plugins/bar/widgets/Indicators.manifest.json +++ b/shell/plugins/bar/widgets/Indicators.manifest.json @@ -26,30 +26,15 @@ "placeholderText": "Search indicators...", "emptyText": "No indicators", "options": [ - { - "value": "StayAwake", - "label": "Stay awake", - "description": "Idle lock and screensaver override" - }, - { - "value": "Dnd", - "label": "Do not disturb", - "description": "Notification silencing" - }, - { - "value": "Reminder", - "label": "Reminder", - "description": "Queued reminder status" - }, { "value": "TmuxAlert", "label": "Tmux alert", "description": "Tmux windows waiting for attention" }, { - "value": "NightLight", - "label": "Night light", - "description": "Blue-light filter" + "value": "Dictation", + "label": "Dictation", + "description": "Voice typing status" }, { "value": "ScreenRecording", @@ -57,9 +42,24 @@ "description": "GPU screen recorder status" }, { - "value": "Dictation", - "label": "Dictation", - "description": "Voice typing status" + "value": "Reminder", + "label": "Reminder", + "description": "Queued reminder status" + }, + { + "value": "NightLight", + "label": "Night light", + "description": "Blue-light filter" + }, + { + "value": "Dnd", + "label": "Do not disturb", + "description": "Notification silencing" + }, + { + "value": "StayAwake", + "label": "Stay awake", + "description": "Idle lock and screensaver override" } ] }, diff --git a/shell/plugins/bar/widgets/Indicators.qml b/shell/plugins/bar/widgets/Indicators.qml index 8360268b..d0f6d1a2 100644 --- a/shell/plugins/bar/widgets/Indicators.qml +++ b/shell/plugins/bar/widgets/Indicators.qml @@ -8,7 +8,7 @@ BarWidget { id: root moduleName: "omarchy.indicators" - readonly property var defaultIndicatorEntries: [ "StayAwake", "Dnd", "Reminder", "TmuxAlert", "NightLight", "ScreenRecording", "Dictation" ] + readonly property var defaultIndicatorEntries: [ "TmuxAlert", "Dictation", "ScreenRecording", "Reminder", "NightLight", "Dnd", "StayAwake" ] readonly property var indicatorEntries: indicatorEntriesFromSettings(settings) property var activeIndicatorIds: [] property var indicatorActiveStates: ({}) @@ -142,7 +142,9 @@ BarWidget { indicatorActiveStates = states var ids = orderedActiveIds(states, activeIndicatorIds) - if (active && ids.indexOf(id) === -1 && hasIndicatorId(id)) ids.push(id) + // The active block sits closest to the clock, so newcomers go on the far + // side of it. Appending would shove everything already showing sideways. + if (active && ids.indexOf(id) === -1 && hasIndicatorId(id)) ids.unshift(id) activeIndicatorIds = ids syncActiveIndicatorModel() } @@ -192,14 +194,6 @@ BarWidget { onHoveredChanged: root.setIndicatorAreaHovered(hovered) } - ActiveIndicatorBlock { - id: activeHorizontalBlock - indicatorsModule: root - indicatorModel: activeIndicatorModel - horizontal: true - reportActiveState: !root.vertical - } - Item { id: inactiveHorizontalArea @@ -223,6 +217,14 @@ BarWidget { onHoveredChanged: root.setIndicatorAreaHovered(hovered) } } + + ActiveIndicatorBlock { + id: activeHorizontalBlock + indicatorsModule: root + indicatorModel: activeIndicatorModel + horizontal: true + reportActiveState: !root.vertical + } } Column { @@ -235,14 +237,6 @@ BarWidget { onHoveredChanged: root.setIndicatorAreaHovered(hovered) } - ActiveIndicatorBlock { - id: activeVerticalBlock - indicatorsModule: root - indicatorModel: activeIndicatorModel - horizontal: false - reportActiveState: root.vertical - } - Item { id: inactiveVerticalArea @@ -266,6 +260,14 @@ BarWidget { onHoveredChanged: root.setIndicatorAreaHovered(hovered) } } + + ActiveIndicatorBlock { + id: activeVerticalBlock + indicatorsModule: root + indicatorModel: activeIndicatorModel + horizontal: false + reportActiveState: root.vertical + } } HoverHandler {