snippets 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. This one will start its own terminal, but only if it's not in a terminal already.
  2. #~ if [ ! -t 0 ]; then # script is executed outside the terminal?
  3. #~ # execute the script inside a terminal window
  4. #~ TILESET=true urxvt -e "$0"
  5. #~ # and abort running the rest of it
  6. #~ exit 0
  7. #~ fi
  8. #~ [[ "x$TILESET" == "x" ]] && echo "Do not run this script inside an existing terminal window.
  9. #~ You will aslo need one of the supported terminal emulators:
  10. #~ ${terms[@]}
  11. #~ " && exit 1
  12. ###############################################################################
  13. other ways of resizing the terminal & retrieving its size in pixels
  14. #~ printf "\x1B[8;24;80t" # resize terminal to standard 80x24
  15. # invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Functions-using-CSI-_-ordered-by-the-final-character_s_
  16. #~ wmctrl -b add,maximized_vert -ir $WINDOWID # maximize vertically
  17. #~ oldifs="$IFS"
  18. #~ IFS=$'\n'
  19. #~ array=( $(xwininfo -id $WINDOWID -wm -stats | grep -oE 'Width: .*|Height: .*|Frame extents: .*') )
  20. #~ IFS="$oldifs"
  21. #~ unset oldifs
  22. #~ width="${array[0]##*: }"
  23. #~ height="${array[1]##*: }"
  24. #~ array[2]="${array[2]##*: }"
  25. #~ frameheight="${array[2]##*, }"
  26. #~ array[2]="${array[2]%, *}"
  27. #~ frameheight=$(( frameheight + ${array[2]##*, } ))
  28. #~ array[2]="${array[2]%, *}"
  29. #~ framewidth="${array[2]##*, }"
  30. #~ array[2]="${array[2]%, *}"
  31. #~ framewidth=$(( framewidth + ${array[2]##*, } ))
  32. #~ unset array
  33. ###############################################################################
  34. function clear24 { # clears the first 24 lines of terminal and puts the cursor to 0 0
  35. for (( i=0 ; i<24 ; i++ )); do
  36. tput cup $i 0
  37. tput el
  38. done
  39. tput cup 0 0
  40. }
  41. ###############################################################################