mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Extract shared swayosd helper
This commit is contained in:
@@ -5,12 +5,8 @@
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Adjust Apple Display Brightness by passing +5000 or -5000 (or any range from 0-60000)"
|
||||
else
|
||||
DEVICE="$(sudo asdcontrol --detect /dev/usb/hiddev* | grep ^/dev/usb/hiddev | cut -d: -f1)"
|
||||
sudo asdcontrol "$DEVICE" -- "$1" >/dev/null
|
||||
VALUE="$(sudo asdcontrol "$DEVICE" | awk -F= '/BRIGHTNESS=/{print $2+0}')"
|
||||
swayosd-client \
|
||||
--monitor "$(hyprctl monitors -j | jq -r '.[]|select(.focused==true).name')" \
|
||||
--custom-icon display-brightness \
|
||||
--custom-progress "$(awk -v v="$VALUE" 'BEGIN{printf "%.2f", v/60000}')" \
|
||||
--custom-progress-text "$(( VALUE * 100 / 60000 ))%"
|
||||
device="$(sudo asdcontrol --detect /dev/usb/hiddev* | grep ^/dev/usb/hiddev | cut -d: -f1)"
|
||||
sudo asdcontrol "$device" -- "$1" >/dev/null
|
||||
value="$(sudo asdcontrol "$device" | awk -F= '/BRIGHTNESS=/{print $2+0}')"
|
||||
omarchy-swayosd-brightness "$(( value * 100 / 60000 ))"
|
||||
fi
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Adjust brightness on the most likely display device.
|
||||
# Usage: omarchy-cmd-brightness <step>
|
||||
|
||||
step="${1:-+5%}"
|
||||
|
||||
@@ -17,10 +18,4 @@ done
|
||||
brightnessctl -d "$device" set "$step" >/dev/null
|
||||
|
||||
# Use SwayOSD to display the new brightness setting.
|
||||
percent=$(brightnessctl -d "$device" -m | cut -d',' -f4 | tr -d '%')
|
||||
|
||||
swayosd-client \
|
||||
--monitor "$(hyprctl monitors -j | jq -r '.[]|select(.focused==true).name')" \
|
||||
--custom-icon display-brightness \
|
||||
--custom-progress "$(awk -v p="$percent" 'BEGIN{printf "%.2f", p/100}')" \
|
||||
--custom-progress-text "${percent}%"
|
||||
omarchy-swayosd-brightness "$(brightnessctl -d "$device" -m | cut -d',' -f4 | tr -d '%')"
|
||||
|
||||
12
bin/omarchy-swayosd-brightness
Executable file
12
bin/omarchy-swayosd-brightness
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Display brightness level using SwayOSD on the current monitor.
|
||||
# Usage: omarchy-swayosd-brightness <percent>
|
||||
|
||||
percent="$1"
|
||||
|
||||
swayosd-client \
|
||||
--monitor "$(hyprctl monitors -j | jq -r '.[]|select(.focused==true).name')" \
|
||||
--custom-icon display-brightness \
|
||||
--custom-progress "$(awk -v p="$percent" 'BEGIN{printf "%.2f", p/100}')" \
|
||||
--custom-progress-text "${percent}%"
|
||||
Reference in New Issue
Block a user