bin: add sway_output, bind to mod+p, menu to mod+t
This commit is contained in:
parent
3b897ba868
commit
3fec545841
2 changed files with 124 additions and 1 deletions
117
bin/sway_output
Executable file
117
bin/sway_output
Executable file
|
@ -0,0 +1,117 @@
|
|||
#!/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
|
8
config
8
config
|
@ -18,6 +18,7 @@ set $term termite
|
|||
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 $suspend_cmd "$HOME/.config/sway/bin/sway_suspend
|
||||
set $volume_cmd "$HOME/.config/sway/bin/sway_volume
|
||||
set $font Cascadia Code PL Regular 10
|
||||
|
@ -79,7 +80,7 @@ bindsym $mod+Shift+q kill
|
|||
bindsym --release button3 kill
|
||||
|
||||
# Start your launcher
|
||||
bindsym $mod+p exec $menu
|
||||
bindsym $mod+t exec $menu
|
||||
|
||||
# Drag floating windows by holding down $mod and left mouse button.
|
||||
# Resize them with right mouse button + $mod.
|
||||
|
@ -187,6 +188,10 @@ bindsym Print exec grim -g "$(slurp)" - | wl-copy
|
|||
# save selection
|
||||
bindsym $mod+Print exec grim -g "$(slurp)" \
|
||||
$(xdg-user-dir PICTURES)/screenshot_$(date +'%Y%m%d_%H%M%S').png
|
||||
#
|
||||
## Output
|
||||
#
|
||||
bindsym $mod+p exec "$term -t float -e $output_cmd"
|
||||
|
||||
#
|
||||
# Gaps
|
||||
|
@ -248,6 +253,7 @@ bindsym $mod+m mode "move"
|
|||
# Window Rules:
|
||||
#
|
||||
for_window [title="nmtui"] floating enable
|
||||
for_window [title="float*"] floating enable
|
||||
for_window [app_id="pavucontrol"] floating enable
|
||||
for_window [app_id="com.nextcloud.desktopclient.nextcloud"] floating enable
|
||||
for_window [app_id=".*"] title_format '<span font_weight="bold">%title</span> <span>(%app_id)</span>'
|
||||
|
|
Loading…
Reference in a new issue