-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresolution
executable file
·89 lines (73 loc) · 1.98 KB
/
resolution
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/zsh
#
# Screen Resize
#
# Only works on my notebook, since absolutely everything
# is hardcoded...
#
SCRIPT_NAME="$(basename $0)"
SCRIPT_VERSION="0.20220228"
source $(dirname $0)/_base.inc.sh
SCREENLAYOUTS_LOCATION="$HOME/.screenlayout"
usage(){
echo "Usage:"
echo "\t$SCRIPT_NAME [resolution|options]"
echo
echo "OPTIONS"
echo "\t--list, -l List available resolutions"
echo "\t--help, -h Display this help text"
echo "\t--version, -V Show version of resolution"
echo
echo "\tIf no resolution is given, you get a nice fancy dialog with"
echo "\ta list of resolutions to choose from."
echo
echo "SCREENLAYOUTS"
echo "\tA screen layout is just an shell script in ~/.screenlayout"
echo "\twhich calls xrandr. Arandr[1] exports screen layouts like this,"
echo "\tand allows arranging multiple screens via mouse."
echo
}
if [[ -z $DISPLAY ]]; then
message_error "\$DISPLAY not set!"
exit 2
fi
if [[ $# -eq 0 ]]; then
res=$(find $SCREENLAYOUTS_LOCATION -type f -executable -exec basename '{}' \; \
| sort \
| sed 's|\.sh$||' \
| zenity --list \
--title "Screen Layout" \
--column "Name" \
--width 350 \
--height 350 \
--text "Please choose a screen layout from the list:")
if [[ $? -eq 1 ]]; then
# User clicked on abort
message_debug "The user clicked [Abort] on the zenity dialog. Doing nothing."
exit 0
fi
elif [[ $1 == "-l" || $1 == "--list" ]]; then
#echo "Available layouts:"
message "Available layouts:"
find $SCREENLAYOUTS_LOCATION -type f -executable -exec basename '{}' \; \
| sort \
| sed 's|\.sh$||'
exit 0
elif [[ $1 == "-h" || $1 == "--help" ]]; then
usage
exit 0
elif [[ ${1:0:1} == "-" ]]; then
message_error "Invalid option: $1"
usage >&2
exit 1
else
res=$1
fi
message_debug "res=\"$res\""
if [[ -x "$SCREENLAYOUTS_LOCATION/$res.sh" ]]; then
env "$SCREENLAYOUTS_LOCATION/$res.sh"
else
# Invalid screen layout
message_error "Invalid layout \"$res\": File not found or nmissing executable bit"
exit 2
fi