From e17cd72683242b524c4350a21fb6fc711158633e Mon Sep 17 00:00:00 2001 From: Andrea Date: Fri, 23 May 2025 10:48:19 +0200 Subject: [PATCH] chore(sway): update config --- .config/sway/config | 11 ++--- .config/sway/scripts/open-screen-recorder.sh | 2 +- .../sway/scripts/screen-brightness-control.sh | 45 +++++++++++++++++++ 3 files changed, 50 insertions(+), 8 deletions(-) create mode 100755 .config/sway/scripts/screen-brightness-control.sh diff --git a/.config/sway/config b/.config/sway/config index 20b3746..2b758a3 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -172,7 +172,7 @@ bindsym $mod+b splith bindsym $mod+v splitv # Switch the current container between different layout styles -bindsym $mod+s layout stacking +# bindsym $mod+s layout stacking bindsym $mod+w layout tabbed bindsym $mod+e layout toggle split @@ -188,15 +188,12 @@ bindsym $mod+d focus mode_toggle # Move focus to the parent container bindsym $mod+a focus parent -# bindsym XF86MonBrightnessDown exec brightnessctl set 5%- -# bindsym XF86MonBrightnessUp exec brightnessctl set 5%+ -bindsym --locked XF86MonBrightnessDown exec brightnessctl set 5%- | sed -En 's/.*\(([0-9]+)%\).*/\1/p' > $WOBSOCK -bindsym --locked XF86MonBrightnessUp exec brightnessctl set 5%+ | sed -En 's/.*\(([0-9]+)%\).*/\1/p' > $WOBSOCK +bindsym --locked XF86MonBrightnessDown exec "$HOME/.config/sway/scripts/screen-brightness-control.sh --decrement" +bindsym --locked XF86MonBrightnessUp exec "$HOME/.config/sway/scripts/screen-brightness-control.sh --increment" -# bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% -# bindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5% bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% && pactl get-sink-volume @DEFAULT_SINK@ | head -n 1 | awk '{print substr($5, 1, length($5)-1)}' > $WOBSOCK bindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5% && pactl get-sink-volume @DEFAULT_SINK@ | head -n 1 | awk '{print substr($5, 1, length($5)-1)}' > $WOBSOCK + bindsym --locked XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle bindsym --locked XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle diff --git a/.config/sway/scripts/open-screen-recorder.sh b/.config/sway/scripts/open-screen-recorder.sh index 6e37f7d..cb62df6 100755 --- a/.config/sway/scripts/open-screen-recorder.sh +++ b/.config/sway/scripts/open-screen-recorder.sh @@ -11,4 +11,4 @@ main() { fi } -main \ No newline at end of file +main $@ \ No newline at end of file diff --git a/.config/sway/scripts/screen-brightness-control.sh b/.config/sway/scripts/screen-brightness-control.sh new file mode 100755 index 0000000..e6ec4ab --- /dev/null +++ b/.config/sway/scripts/screen-brightness-control.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +increment() { + brightnessctl set 5%+ +} + +decrement() { + local current_value=$(brightnessctl get) + + if [[ "$current_value" == "4" ]]; then + return 0 + fi + + if [[ "$current_value" == "6000" ]]; then + brightnessctl set 4 + else + brightnessctl set 5%- + fi +} + +main() { + local WOBSOCK="$XDG_RUNTIME_DIR/wob.sock" + + if [[ -z "$1" ]]; then + echo "Provide --increment or --decrement" + exit 1 + fi + + case "$1" in + "--increment") + increment + ;; + "--decrement") + decrement + ;; + *) + echo "Invalid option, use only --increment or --decrement" + exit 1 + ;; + esac + + brightnessctl info | sed -En 's/.*\(([0-9]+)%\).*/\1/p' > $WOBSOCK +} + +main $@ \ No newline at end of file