#!/bin/bash set -e [ -n "$DEBUG" ] && set -x get_output() { swaymsg -t get_outputs | jq -cr '.[] | select(.type=="output") | [.name, .make + " " + .model] | @tsv' | menu --accept-single | cut -d $'\t' -f 1 } list_modes() { local output=$1 swaymsg -t get_outputs | jq -cr --arg name "$output" '.[] | select(.type=="output" and .name==$name) | .modes[] | [([.width, "x", .height, "@", .refresh, "Hz"]|join("")), .picture_aspect_ratio // ""] | @tsv' } output=$(get_output) mode=$( ( list_modes "$output" echo -e "\tset scale..." ) | column -t -s $'\t' | menu) case "$mode" in *"set scale"*) scale=$(echo -e "1.0\n1.5\n2.0" | MENU_PROMPT="set scale" menu) exec swaymsg output "$output" scale "$scale" ;; *) exec swaymsg output "$output" mode "$mode" ;; esac