it2attention (1596B)
1 #!/bin/bash 2 3 # tmux requires unrecognized OSC sequences to be wrapped with DCS tmux; 4 # <sequence> ST, and for all ESCs in <sequence> to be replaced with ESC ESC. It 5 # only accepts ESC backslash for ST. 6 function print_osc() { 7 if [[ $TERM == screen* ]] ; then 8 printf "\033Ptmux;\033\033]" 9 else 10 printf "\033]" 11 fi 12 } 13 14 # More of the tmux workaround described above. 15 function print_st() { 16 if [[ $TERM == screen* ]] ; then 17 printf "\a\033\\" 18 else 19 printf "\a" 20 fi 21 } 22 23 function show_help() { 24 echo "Usage:" 1>& 2 25 echo " $(basename $0) start" 1>& 2 26 echo " Begin bouncing the dock icon if another app is active" 1>& 2 27 echo " $(basename $0) stop" 1>& 2 28 echo " Stop bouncing the dock icon if another app is active" 1>& 2 29 echo " $(basename $0) once" 1>& 2 30 echo " Bounce the dock icon once if another app is active" 1>& 2 31 echo " $(basename $0) fireworks" 1>& 2 32 echo " Show an explosion animation at the cursor" 1>& 2 33 } 34 35 function start_bounce() { 36 print_osc 37 printf "1337;RequestAttention=1" 38 print_st 39 } 40 41 function stop_bounce() { 42 print_osc 43 printf "1337;RequestAttention=0" 44 print_st 45 } 46 47 function bounce_once() { 48 print_osc 49 printf "1337;RequestAttention=once" 50 print_st 51 } 52 53 function fireworks() { 54 print_osc 55 printf "1337;RequestAttention=fireworks" 56 print_st 57 } 58 59 ## Main 60 if [[ $# == 0 ]] 61 then 62 show_help 63 exit 1 64 fi 65 66 if [[ $1 == start ]] 67 then 68 start_bounce 69 elif [[ $1 == stop ]] 70 then 71 stop_bounce 72 elif [[ $1 == once ]] 73 then 74 bounce_once 75 elif [[ $1 == fireworks ]] 76 then 77 fireworks 78 else 79 show_help 80 exit 1 81 fi 82