From The Compiler, 6 Years ago, written in Bash.
Embed
  1. #!/bin/bash
  2. # vim: set fileencoding=utf-8 ts=4 sts=4 sw=4 tw=80 expandtab :
  3.  
  4. # Copyright (C) 2012 Florian Bruhin <me@the-compiler.org>
  5.  
  6. # onboardctl is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # onboardctl is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with onboardctl  If not, see <http://www.gnu.org/licenses/>.
  18.  
  19.  
  20. # Sets the hlwm-padding and launches onboard
  21. launch() {
  22.     currot=$(xrandr --verbose -q -o normal --dryrun | \
  23.              sed -n 's/^Current rotation - //p')
  24.     case $currot in
  25.         normal|reverse) x=0; y=368;  w=1366; h=400 ;;
  26.         left|right)     x=0; y=1066; w=768;  h=300 ;;
  27.     esac
  28.     [[ $1 == onlypad ]] || onboard -x "$x" -y "$y" -s "${w}x${h}" &
  29.     pad "$h" &
  30. }
  31.  
  32. # Gets the current onboard-state
  33. isrunning() { pgrep '^onboard$' &>/dev/null ;}
  34.  
  35. # Toggles the onboard-state (shown/hidden)
  36. toggle() { isrunning && hide || launch ;}
  37.  
  38. # Kills onboard if it is running
  39. hide() { isrunning && killall onboard && herbstclient pad 0 "" "" 0 "" ;}
  40.  
  41. # Sets the herbstluftwm padding
  42. pad() { herbstclient pad 0 "" "" "$1" "" ;}
  43.  
  44. # Handles screen rotation
  45. rotate() { isrunning && launch onlypad ;}
  46.  
  47. case $1 in
  48.     hide|kill) hide ;;
  49.     launch|show|launchshow) launch ;;
  50.     state) isrunning ;;
  51.     toggle) toggle ;;
  52.     rotate) rotate ;;
  53. esac