xctl 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. usage () {
  3. cat <<EOF>&2
  4. Usage: ${0##*/} [OPERATION]
  5. When no OPERATION is specified, reset the screen to the defaults.
  6. Apply OPERATION to the X screen renderer:
  7. multi VIDEOPORT
  8. starwars
  9. zoomin
  10. zoomout
  11. EOF
  12. }
  13. current=$(xrandr | sed -n "/current/{n;p;q}" | cut -f1 -d" ")
  14. ## Other unreliable options:
  15. # xrandr | grep -m1 "\<connected\>" | cut -f1 -d" "
  16. # xrandr | awk 'NR==2 {print $1; exit}'
  17. if [ $# -eq 0 ]; then
  18. xrandr --output "$current" --auto --transform none --brightness 1 && \
  19. xrandr -s "$(xrandr | awk '/^ / {print $1;exit}')"
  20. exit
  21. fi
  22. case "$1" in
  23. multi)
  24. [ $# -lt 2 ] && usage && exit 1
  25. xrandr --output "$2" --auto --right-of "$current" ;;
  26. starwars)
  27. xrandr --output "$current" --transform 1.24,0.16,-124,0,1.24,0,0,0.000316,1 ;;
  28. zoomin)
  29. xrandr --output "$current" --scale 0.8x0.8 ;;
  30. zoomout)
  31. xrandr --output "$current" --scale 1.2x1.2 ;;
  32. *)
  33. usage;;
  34. esac
  35. ## Old code.
  36. # xscreen () {
  37. # ## Does not work?
  38. # cvt $1 $2
  39. # echo "$(cvt $1 $2 | tail -1 | cut -d' ' -f2-)"
  40. # xrandr --newmode "$(cvt $1 $2 | tail -1 | cut -d' ' -f2-)"
  41. # }