Skip to content

Instantly share code, notes, and snippets.

@nikp123
Last active January 11, 2021 19:17
Show Gist options
  • Save nikp123/de97260620146b8f41d0134ee1f90127 to your computer and use it in GitHub Desktop.
Save nikp123/de97260620146b8f41d0134ee1f90127 to your computer and use it in GitHub Desktop.
Changing display resolutions in sway
#!/bin/bash
swaymsg="$(swaymsg -t get_outputs -r)"
numOfModes=$(echo $swaymsg|jq -r '.[0].modes | length')
modes=''
widths="$(echo $swaymsg|jq -r '.[0].modes[].width')"
IFS=$'\n' widths=($widths)
IFS=$' '
heights="$(echo $swaymsg|jq -r '.[0].modes[].height')"
IFS=$'\n' heights=($heights)
IFS=$' '
sum=''
for (( i=0; i<numOfModes; i++ )); do
modes[$i]=$(echo ${widths[$i]}x${heights[$i]})
if [ ${modes[$i]} = ${modes[((i-1))]} ]; then
continue
fi
sum+="${modes[$i]}\n"
done
swaymsg output $(echo $swaymsg|jq -r '.[0].name') mode $(printf $sum | rofi -dmenu -i)
@nikp123
Copy link
Author

nikp123 commented Jan 11, 2021

@layus Yeah, just read about it. For those unaware, it's a GUI configuration tool for wlroots compositors, which includes sway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment