summary refs log tree commit diff
path: root/bin/modemenu
blob: 64ef18ed5927ae79e972e4ee51e4aac8421611e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/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