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"
@@ -145,23 +156,22 @@ _arandr_empty() {
_help() { _help() {
echo 'DISPtool echo 'DISPtool
Running without arguments shows display configuration choices Running without arguments shows display configuration choices
help Get this help message
setup Setup display names
all Try to turn all displays on
primary Clone primary display resolution to all other displays
Display configurations:
help Get this help message 0 Run "arandr" to setup manually
setup Setup display names 1 Main display only
all Try to turn all displays on 2 Presentation: Main and external screen clones
3 Workstation: Run your workstation mode, setup in the configuration file
Display configurations: Second argument to any previous sets the gamma correction value
Configuration file: '$CONFIG'
0 Run "arandr" to setup manually Display settings saved with arandr are displayed last
1 Main display only
2 Presentation: Main and external screen clones
3 Workstation: Run your workstation mode, setup in the configuration file
Second argument to any previous sets the gamma correction value
Configuration file: '$CONFIG'
Display settings saved with arandr are displayed last
' '
_list_arandr _list_arandr
exit exit
@@ -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; ;;