add resolution cloner

This commit is contained in:
Ville Rantanen
2019-12-18 10:21:35 +02:00
parent f21cbfd5fb
commit b0c9893a63

View File

@@ -26,6 +26,17 @@ _allon() {
exit exit
} }
_cloneprimary() {
if [ -z "$PRIMARYRESOLUTION" ]; then
echo "Could not detect resolution"
exit
fi
_list_connected | while read display; do
_xrandr --output $display --mode "$PRIMARYRESOLUTION"
done
exit
}
_display_main() { _display_main() {
[[ -f "$CONFIG" ]] || { [[ -f "$CONFIG" ]] || {
echo "ERROR: You do not have configuration yet" echo "ERROR: You do not have configuration yet"
@@ -146,11 +157,10 @@ _help() {
echo 'DISPtool echo 'DISPtool
Running without arguments shows display configuration choices Running without arguments shows display configuration choices
help Get this help message help Get this help message
setup Setup display names setup Setup display names
all Try to turn all displays on all Try to turn all displays on
primary Clone primary display resolution to all other displays
Display configurations: Display configurations:
0 Run "arandr" to setup manually 0 Run "arandr" to setup manually
@@ -178,6 +188,8 @@ _help() {
g=1 g=1
[[ -z "$2" ]] || g=$2 [[ -z "$2" ]] || g=$2
i=$1 i=$1
PRIMARYRESOLUTION=$( xrandr | grep -w primary | grep -o '[0-9]\+x[0-9]\++[0-9]\++[0-9]\+' | grep -o '[0-9]\+x[0-9]\+' )
if [ -z "$1" ]; then if [ -z "$1" ]; then
echo "Currently connected displays:" echo "Currently connected displays:"
xrandr | grep --color=always -e ".* connected" -e '.*\*' | awk '{ print $1,$2,$3} ' xrandr | grep --color=always -e ".* connected" -e '.*\*' | awk '{ print $1,$2,$3} '
@@ -189,6 +201,7 @@ if [ -z "$1" ]; then
2 Presentation: Main and all external screen clones (1024x768) 2 Presentation: Main and all external screen clones (1024x768)
3 Workstation: Your personal configration ('$WORKSTATIONLEFT + $WORKSTATIONRIGHT', panel on '$PANEL') 3 Workstation: Your personal configration ('$WORKSTATIONLEFT + $WORKSTATIONRIGHT', panel on '$PANEL')
a All displays on a All displays on
p All displays on, with the resolution of primary display ('$PRIMARYRESOLUTION')
s Create and edit configuration '$CONFIGURED' s Create and edit configuration '$CONFIGURED'
Settings by arandr:' Settings by arandr:'
@@ -199,6 +212,7 @@ fi
case $i in case $i in
"a"*) _allon; ;; "a"*) _allon; ;;
"p"*) _cloneprimary; ;;
"s"*) _setup; ;; "s"*) _setup; ;;
0) ( arandr & ); ;; 0) ( arandr & ); ;;
1) _display_main; ;; 1) _display_main; ;;