Extract turning brightness devices on/off
This commit is contained in:
@@ -1,15 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# omarchy:summary=Adjust brightness on the most likely display device.
|
# omarchy:summary=Adjust brightness on the most likely display device.
|
||||||
# omarchy:args=<step>
|
# omarchy:args=<step|off|on>
|
||||||
|
|
||||||
step="${1:-+5%}"
|
step="${1:-+5%}"
|
||||||
|
|
||||||
if omarchy-hyprland-monitor-focused-apple; then
|
|
||||||
omarchy-brightness-display-apple "$step"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Start with the first possible output, then refine to the most likely given an order heuristic.
|
# Start with the first possible output, then refine to the most likely given an order heuristic.
|
||||||
device="$(ls -1 /sys/class/backlight 2>/dev/null | head -n1)"
|
device="$(ls -1 /sys/class/backlight 2>/dev/null | head -n1)"
|
||||||
for candidate in amdgpu_bl* intel_backlight acpi_video*; do
|
for candidate in amdgpu_bl* intel_backlight acpi_video*; do
|
||||||
@@ -19,6 +14,19 @@ for candidate in amdgpu_bl* intel_backlight acpi_video*; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ $step == "off" ]]; then
|
||||||
|
hyprctl dispatch dpms off >/dev/null 2>&1
|
||||||
|
exit 0
|
||||||
|
elif [[ $step == "on" ]]; then
|
||||||
|
hyprctl dispatch dpms on >/dev/null 2>&1
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if omarchy-hyprland-monitor-focused-apple; then
|
||||||
|
omarchy-brightness-display-apple "$step"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
# Current brightness percentage
|
# Current brightness percentage
|
||||||
current=$(brightnessctl -d "$device" -m | cut -d',' -f4 | tr -d '%')
|
current=$(brightnessctl -d "$device" -m | cut -d',' -f4 | tr -d '%')
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# omarchy:summary=Adjust keyboard backlight brightness using available steps.
|
# omarchy:summary=Adjust keyboard backlight brightness using available steps.
|
||||||
# omarchy:args=<up|down|cycle>
|
# omarchy:args=<up|down|cycle|off|restore>
|
||||||
|
|
||||||
direction="${1:-up}"
|
direction="${1:-up}"
|
||||||
|
|
||||||
@@ -19,6 +19,14 @@ if [[ -z $device ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $direction == "off" ]]; then
|
||||||
|
brightnessctl -sd "$device" set 0 >/dev/null
|
||||||
|
exit 0
|
||||||
|
elif [[ $direction == "restore" ]]; then
|
||||||
|
brightnessctl -rd "$device" >/dev/null
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Get current and max brightness to determine step size.
|
# Get current and max brightness to determine step size.
|
||||||
max_brightness="$(brightnessctl -d "$device" max)"
|
max_brightness="$(brightnessctl -d "$device" max)"
|
||||||
current_brightness="$(brightnessctl -d "$device" get)"
|
current_brightness="$(brightnessctl -d "$device" get)"
|
||||||
|
|||||||
@@ -5,6 +5,5 @@
|
|||||||
# omarchy:name=wake
|
# omarchy:name=wake
|
||||||
# omarchy:examples=omarchy system wake
|
# omarchy:examples=omarchy system wake
|
||||||
|
|
||||||
hyprctl dispatch dpms on >/dev/null 2>&1
|
omarchy-brightness-display on
|
||||||
brightnessctl -r >/dev/null 2>&1
|
omarchy-brightness-keyboard restore
|
||||||
brightnessctl -rd '*::kbd_backlight' >/dev/null 2>&1
|
|
||||||
|
|||||||
Reference in New Issue
Block a user