diff --git a/.gitignore b/.gitignore index fedcc65..daa0836 100644 --- a/.gitignore +++ b/.gitignore @@ -92,6 +92,8 @@ eww/scripts/* sway/scripts/* !sway/scripts/power-menu.sh !sway/scripts/screenshot.sh +!sway/scripts/ws-to-current.sh +!sway/scripts/power-aware-effects.sh # bin !bin diff --git a/sway/config.d/80-autostart.conf b/sway/config.d/80-autostart.conf index ce0ed1b..629c1bf 100644 --- a/sway/config.d/80-autostart.conf +++ b/sway/config.d/80-autostart.conf @@ -4,6 +4,7 @@ exec swayidle -w exec wlsunset -l 46.1 -L 14.5 exec pkill -x wob; rm -f $wobs && mkfifo $wobs && tail -f $wobs | wob exec wl-paste --watch cliphist store +exec ~/.config/sway/scripts/power-aware-effects.sh exec protonmail-bridge -n # traditional "start when os starts" programs diff --git a/sway/scripts/power-aware-effects.sh b/sway/scripts/power-aware-effects.sh new file mode 100755 index 0000000..8d82471 --- /dev/null +++ b/sway/scripts/power-aware-effects.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# toggle swayfx blur and shadows based on battery state + +while true; do + status=$(cat /sys/class/power_supply/BAT1/status 2>/dev/null || cat /sys/class/power_supply/BAT0/status) + + if [ "$status" = "Discharging" ]; then + swaymsg blur off + swaymsg shadows off + else + swaymsg blur on + swaymsg shadows on + fi + + sleep 30 +done diff --git a/sway/scripts/ws-to-current.sh b/sway/scripts/ws-to-current.sh new file mode 100755 index 0000000..3f11412 --- /dev/null +++ b/sway/scripts/ws-to-current.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# switch to workspace and move it to the currently focused output +output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') +swaymsg "workspace number $1, move workspace to output $output"