toggle_vga.sh

From Ritchie, 9 Years ago, written in Bash, viewed 156 times.
URL http://minetest.wjake.com/stikked/view/db151886 Embed
Download Paste or View Raw
  1. #/bin/bash
  2.  
  3. #simple script to toggle secondary monitor output on or off
  4. #uses dcop from KDE 3.5 to send notify info
  5. #dcop messages are in Czech language
  6. #for use with "Input actions" in KDE control center is recommended to set "Keyboard shortcut -> Command/URL (simple)" and then write to text box "URL/command to execute": bash /home/user/.local/bin/toggle_vga.sh
  7. # ^^ without bash in text box it behaves as secondary output is disconnected
  8.  
  9. #configuration of selected outputs regarding to output of command "xrandr"
  10. PRIMARY="DVI-I-1"
  11. SECONDARY="VGA-0"
  12. SECONDARY_MODE="1280x1024"
  13.  
  14. #check if xrandr is installed
  15. if [ `which xrandr | wc -l` -gt 0 ] ;
  16. then
  17. #       echo "xrandr is ok"
  18. #       dcop knotify default notify toggle_vga "VGA přepínač" "xrandr je nainstalovaný" '' '' 16 0
  19.  
  20.         #check if $SECONDARY output is connected
  21.         if [ `xrandr | grep $SECONDARY | grep connected | wc -l` == 1 ] ;
  22.         then
  23. #               echo "$SECONDARY is connected"
  24.  
  25.                 #check if $SECONDARY is enabled
  26.                 if [ `xrandr | grep $SECONDARY | grep connected | grep $SECONDARY_MODE | wc -l` == 1 ] ;
  27.                 then
  28. #                       echo "$SECONDARY is enabled with mode $SECONDARY_MODE"
  29.                         #disabling $SECONDARY
  30.                         dcop knotify default notify toggle_vga "VGA přepínač" "Vypínám výstup $SECONDARY" '' '' 16 0
  31.                         sleep 3
  32.                         xrandr --output $SECONDARY --off
  33.                 else
  34. #                       echo "$SECONDARY is disabled"
  35.                         #enabling $SECONDARY
  36.                         dcop knotify default notify toggle_vga "VGA přepínač" "Zapínám výstup $SECONDARY" '' '' 16 0
  37.                         sleep 3
  38.                         xrandr --output $SECONDARY --mode $SECONDARY_MODE --right-of $PRIMARY
  39.                 fi
  40.         else
  41. #               echo "$SECONDARY is not connected"
  42.                 dcop knotify default notify toggle_vga "VGA přepínač" "$SECONDARY je odpojeno" '' '' 16 0
  43.         fi
  44.  
  45. else
  46. #       echo "xrandr is not installed"
  47.         dcop knotify default notify toggle_vga "VGA přepínač" "xrandr není nainstalovaný" '' '' 16 0
  48. fi
  49.  

Reply to "toggle_vga.sh"

Here you can reply to the paste above