displaycon (2143B)
1 #!/usr/alt/bin/rc 2 3 disp=(DisplayPort-0 HDMI-A-0) 4 5 nl=' 6 ' 7 8 oldifs=$ifs 9 ifs=$nl 10 connected=`{xrandr | grep '\sconnected'} 11 ifs=$oldifs 12 13 fn display_location_orientation { 14 xrandr --output $disp(1) --auto --scale 1.0x1.0 --primary 15 xrandr --output $disp(2) --$1 $disp(1) --rotate $2 --auto 16 } 17 18 fn display_one { 19 ifs=$nl 20 # NOTE: covers disconnected too 21 all_screens=`{xrandr | grep 'connected'} 22 ifs=$oldifs 23 extra_args=`{printf '%s' $all_screens ^ $nl | grep -v '^'$1 | awk '{print "--output", $1, "--off"}'} 24 xrandr --output $1 --primary --auto --scale 1.0x1.0 $extra_args 25 } 26 27 fn display_duplicate { 28 ifs=' ' 29 primary=`{printf '%s' $connected ^ $nl | dmenu -i -l $#dmenu_args -p 'Optimize for:'} 30 secondary=`{printf '%s' $connected ^ $nl | grep -v '^'$primary(1)} 31 ifs=$oldifs 32 33 ifs='x' 34 primary_resolution=`{xrandr -q | sed -n '/^'$primary(1) ^ '/{n;p}' | awk '{printf $1}'} 35 secondary_resolution=`{xrandr -q | sed -n '/^'$secondary(1) ^ '/{n;p}' | awk '{printf $1}'} 36 ifs=$oldifs 37 38 scale_x=`{echo $primary_resolution(1)' / '$secondary_resolution(1) | bc -l} 39 scale_y=`{echo $primary_resolution(2)' / '$secondary_resolution(2) | bc -l} 40 41 echo $scale_x^'x'^$scale_y 42 xrandr --output $primary(1) --auto --scale 1.0x1.0 --primary 43 xrandr --output $secondary(1) --same-as $primary(1) --auto --scale $scale_x'x'^$scale_y 44 } 45 46 dmenu_args=( \ 47 'DLL: Display Left of with Left Rotation' \ 48 'DLN: Display Left of with Normal Rotation' \ 49 'DBN: Display Below with Normal Rotation' \ 50 'ONE: Primary Display Only' \ 51 'DUP: Duplicate Display' \ 52 ) 53 54 switch ($#connected) { 55 case 1 56 ifs=' ' 57 connected_display=`{printf '%s' $connected ^ $nl} 58 display_one $connected_display(1) 59 case * 60 ifs=':' 61 func=`{printf '%s' $dmenu_args ^ $nl | dmenu -i -l $#dmenu_args -p 'Display Profile?'} 62 ifs=$oldifs 63 switch ($func(1)) { 64 case DLL 65 display_location_orientation 'left-of' 'left' 66 case DLN 67 display_location_orientation 'left-of' 'normal' 68 case DBN 69 display_location_orientation 'below' 'normal' 70 case ONE 71 display_one $disp(1) 72 case DUP 73 display_duplicate 74 } 75 } 76 77 bgs -z $home/.config/h_wallpaper.jpg