Combine here too
This commit is contained in:
@@ -1,10 +1,27 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# omarchy:summary=Adjust brightness on the most likely display device.
|
# omarchy:summary=Show or adjust brightness on the most likely display device.
|
||||||
# omarchy:args=<+N%|N%-|N%|off|on>
|
# omarchy:args=[+N%|N%-|N%|off|on]
|
||||||
# omarchy:examples=omarchy brightness display +5% | omarchy brightness display 5%- | omarchy brightness display 50% | omarchy brightness display off | omarchy brightness display on
|
# omarchy:examples=omarchy brightness display | omarchy brightness display +5% | omarchy brightness display 5%- | omarchy brightness display 50% | omarchy brightness display off | omarchy brightness display on
|
||||||
|
|
||||||
step="${1:-+5%}"
|
display_brightness() {
|
||||||
|
local device="$1"
|
||||||
|
|
||||||
|
brightnessctl -d "$device" -m 2>/dev/null | awk -F, '{ gsub("%", "", $4); print $4; found=1 } END{ exit !found }'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (( $# == 0 )) || [[ ${1:-} == "get" ]]; then
|
||||||
|
if omarchy-hyprland-monitor-focused-apple; then
|
||||||
|
omarchy-brightness-display-apple
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
device="$(omarchy-hw-display)" || exit 1
|
||||||
|
display_brightness "$device"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
step="$1"
|
||||||
|
|
||||||
if [[ $step == "off" ]]; then
|
if [[ $step == "off" ]]; then
|
||||||
hyprctl dispatch 'hl.dsp.dpms({ action = "disable" })' >/dev/null 2>&1
|
hyprctl dispatch 'hl.dsp.dpms({ action = "disable" })' >/dev/null 2>&1
|
||||||
@@ -14,12 +31,10 @@ elif [[ $step == "on" ]]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
runtime_dir="${XDG_RUNTIME_DIR:-/tmp}"
|
|
||||||
|
|
||||||
# Drop overlapping brightness key events so concurrent invocations do not race.
|
# Drop overlapping brightness key events so concurrent invocations do not race.
|
||||||
# Hardware key repeat present on some devices can otherwise glitch OSD rendering.
|
# Hardware key repeat present on some devices can otherwise glitch OSD rendering.
|
||||||
exec 9>"$runtime_dir/omarchy-brightness-display.lock"
|
exec {lock_fd}>"${XDG_RUNTIME_DIR:-/tmp}/omarchy-brightness-display.lock"
|
||||||
flock -n 9 || exit 0
|
flock -n "$lock_fd" || exit 0
|
||||||
|
|
||||||
if omarchy-hyprland-monitor-focused-apple; then
|
if omarchy-hyprland-monitor-focused-apple; then
|
||||||
omarchy-brightness-display-apple "$step"
|
omarchy-brightness-display-apple "$step"
|
||||||
@@ -29,7 +44,7 @@ fi
|
|||||||
device="$(omarchy-hw-display)" || exit 1
|
device="$(omarchy-hw-display)" || exit 1
|
||||||
|
|
||||||
# Current brightness percentage
|
# Current brightness percentage
|
||||||
current=$(brightnessctl -d "$device" -m | cut -d',' -f4 | tr -d '%')
|
current=$(display_brightness "$device") || exit 1
|
||||||
|
|
||||||
# Apply non-uniform step size: 1% steps if at or below 5%, otherwise set an
|
# Apply non-uniform step size: 1% steps if at or below 5%, otherwise set an
|
||||||
# absolute target percentage to avoid raw backlight rounding causing uneven OSD steps.
|
# absolute target percentage to avoid raw backlight rounding causing uneven OSD steps.
|
||||||
@@ -55,4 +70,4 @@ fi
|
|||||||
|
|
||||||
# Set brightness of the display device.
|
# Set brightness of the display device.
|
||||||
brightnessctl -d "$device" set "$step" >/dev/null
|
brightnessctl -d "$device" set "$step" >/dev/null
|
||||||
omarchy-osd -i brightness -p "$(brightnessctl -d "$device" -m | cut -d',' -f4 | tr -d '%')"
|
omarchy-osd -i brightness -p "$(display_brightness "$device")"
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# omarchy:summary=Get brightness for the most likely display device.
|
|
||||||
# omarchy:examples=omarchy-brightness-display-get
|
|
||||||
|
|
||||||
if omarchy-hyprland-monitor-focused-apple; then
|
|
||||||
omarchy-brightness-display-apple-get
|
|
||||||
else
|
|
||||||
brightnessctl -d "$(omarchy-hw-display)" -m 2>/dev/null | awk -F, '{ gsub("%", "", $4); print $4; found=1 } END{ exit !found }'
|
|
||||||
fi
|
|
||||||
@@ -129,7 +129,7 @@ Item {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: stateProc
|
id: stateProc
|
||||||
command: ["bash", "-lc", "omarchy-brightness-display-get 2>/dev/null || true; monitors_json=$(hyprctl monitors all -j); printf '%s\\n' \"$monitors_json\" | jq -r 'def internal: test(\"^(eDP|LVDS|DSI)-\"); ([.[] | select(.name | internal)][0].name // \"\"), ([.[] | select((.name | internal) | not)][0].name // \"\"), ([.[] | select((.name | internal) and .disabled != true)][0].name // \"\"), ([.[] | select((.name | internal) and .mirrorOf != \"none\")][0].mirrorOf // \"\")'; omarchy-hyprland-monitor-focused 2>/dev/null || echo; omarchy-hyprland-monitor-scaling-get 2>/dev/null || echo; printf '%s\\n' \"$monitors_json\" | jq -c '[.[] | {name, enabled:(.disabled != true), focused:(.focused == true)}]'"]
|
command: ["bash", "-lc", "omarchy-brightness-display 2>/dev/null || true; monitors_json=$(hyprctl monitors all -j); printf '%s\\n' \"$monitors_json\" | jq -r 'def internal: test(\"^(eDP|LVDS|DSI)-\"); ([.[] | select(.name | internal)][0].name // \"\"), ([.[] | select((.name | internal) | not)][0].name // \"\"), ([.[] | select((.name | internal) and .disabled != true)][0].name // \"\"), ([.[] | select((.name | internal) and .mirrorOf != \"none\")][0].mirrorOf // \"\")'; omarchy-hyprland-monitor-focused 2>/dev/null || echo; omarchy-hyprland-monitor-scaling-get 2>/dev/null || echo; printf '%s\\n' \"$monitors_json\" | jq -c '[.[] | {name, enabled:(.disabled != true), focused:(.focused == true)}]'"]
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
waitForEnd: true
|
waitForEnd: true
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
|
|||||||
Reference in New Issue
Block a user