sway: switch output configuration to swayout

This commit is contained in:
Konstantin Koslowski 2022-03-13 12:45:50 +01:00
parent 6a19f7b604
commit 26a3771dcf
4 changed files with 7 additions and 124 deletions

View file

@ -1,117 +0,0 @@
#!/bin/zsh
source $HOME/.config/sway/bin/sway_helpers
CMD=$HOME/.config/sway/bin/sway_output
# BAT_PATH=/sys/class/power_supply
# BAT=BAT0
# MODE=suspend-then-hibernate
## helpers
function _get() {
_check_app jq
data=()
swaymsg -t get_outputs | jq -r ".[] | .$1" | while read line; do
line=${line:gs/ /_}
data+=($line)
done
echo $data
}
function _outputs() {
make=( $(_get make) )
model=( $(_get model) )
serial=( $(_get serial) )
name=( $(_get name) )
active=( $(_get active) )
for i in $(seq ${#make[@]}); do
ac=${active[$i]/true/active}
ac=${ac/false/inactive}
printf " - %2d %6s %10s %20s %15s %10s\n" $i ${name[$i]} "($ac)" ${make[$i]} ${model[$i]} ${serial[$i]}
done
}
function _enable() {
n=( $(_get name) )
swaymsg output ${n[$1]} enable
}
function _disable() {
n=( $(_get name) )
swaymsg output ${n[$1]} disable
}
function _interactive() {
echo "outputs (any key to abort)"
_outputs
num=$(_outputs | wc -l)
read -k 1 "o?select output: "
if [ $o -le $num ]; then
echo ""
echo ""
else
echo "error: invalid output selected: $o"
return 1
fi
echo "actions (any key to abort)"
printf " - %2s %6s\n" "1" "enable"
printf " - %2s %6s\n" "2" "disable"
read -k 1 "a?select action: "
if [ $a -le 2 ]; then
echo ""
echo ""
case $a in
1)
echo "enabling $o"
_enable $o
;;
2)
echo "disabling $o"
_disable $o
;;
esac
else
echo "error: invalid action selected $a"
return 1
fi
}
# generate enab
function _nag() {
_check_app swaynag
name=( $(_get name) )
z=()
# for n in $name; do
# z+=" -z \"enable $n\" \"$CMD enable $n\""
# z+=" -z \"disable $n\" \"$CMD disable $n\""
# done
# swaynag -m "control outputs" $(echo ${z[@]})
# swaynag -m "control outputs" $(echo ${z})
}
## main
# _log OUTPUTS INFO args: $*
case $1 in
o*)
echo "outputs: "
_outputs
;;
e*)
_enable $2
;;
d*)
_disable $2
;;
n*)
_nag
;;
-h|--help|help)
echo "invalid argument: \"$1\""
echo "arguments: [outputs|enable #|disable #]"
;;
*)
_interactive
;;
esac

2
config
View file

@ -19,7 +19,7 @@ set $term_cmd foot -T float
set $background $HOME/Cloud/xkonni/Pictures/wallpaper/5k_bavarian_forest_bw.jpg
set $lock_cmd $HOME/.config/sway/bin/sway_lock
set $brightness_cmd $HOME/.config/sway/bin/sway_brightness
set $output_cmd $HOME/.config/sway/bin/sway_output
set $output_cmd $HOME/.local/bin/swayout
set $suspend_cmd $HOME/.config/sway/bin/sway_suspend
set $volume_cmd $HOME/.config/sway/bin/sway_volume
set $move_cmd $HOME/.config/sway/bin/sway_move

View file

@ -4,11 +4,11 @@ set $intern "Unknown 0x633D 0x00000000"
set $extern "Goldstar Company Ltd 38GN950 008NTLEFY912"
### Output configuration
output $intern position 0 0
output $extern position 1920 0 mode 3840x1600
output $intern mode 1920x1080
output $extern mode 3840x1600
bindswitch --reload --locked lid:on output $intern disable; output $extern position 0 0
bindswitch --reload --locked lid:off output $intern enable; output $extern position 1920 0
bindswitch --reload --locked lid:on output $intern disable
bindswitch --reload --locked lid:off output $intern enable
### Input configuration
input "1160:4618:DELL09BE:00_0488:120A_Touchpad" {

View file

@ -4,8 +4,8 @@ set $intern "Unknown 0x5B2D 0x00000000"
set $extern "Goldstar Company Ltd 38GN950 008NTLEFY912"
### Output configuration
output $intern position 0 0
output $extern position 1920 0 mode 3840x1600
output $intern mode 1920x1080
output $extern mode 3840x1600
bindswitch --reload --locked lid:on output $intern disable
bindswitch --reload --locked lid:off output $intern enable