dotfiles

regexghost dotfiles and scripts
git clone https://git.regexghost.com/dotfiles.git
Log | Files | Refs | README

jwm-scratchpad.sh (986B)


      1 #!/bin/sh
      2 
      3 scratchpad="$(xdotool search --class "scratchpad")"
      4 old_focus="$(cat ~/.cache/old_window)"
      5 
      6 launch_window () {
      7 	tmux new-session -d -s "buffer_tmux" 'nano ~/Downloads/buffer.md; bash'
      8 	setsid /usr/local/bin/st -c "scratchpad" -t "buffer" -e tmux attach -t "buffer_tmux" &
      9 	sleep 0.5
     10 	scratchpad="$(xdotool search --class "scratchpad")"
     11 	xdotool windowmove "$scratchpad" 610 300
     12 }
     13 
     14 hide_window () {
     15 	xdotool windowmove "$scratchpad" -1000 -1000
     16 #	xdotool windowactivate "$old_focus"
     17 #	xdotool set_desktop_for_window "$scratchpad" 5
     18 	xdotool windowminimize "$scratchpad"
     19 }
     20 
     21 show_window () {
     22 #	xdotool getactivewindow > ~/.cache/old_window
     23 	desktop="$(xdotool get_desktop)"
     24 	xdotool set_desktop_for_window "$scratchpad" "$desktop"
     25 	xdotool windowactivate "$scratchpad"
     26 	xdotool windowmove "$scratchpad" 610 300
     27 }
     28 
     29 if [ "$scratchpad" = "" ]; then
     30 	launch_window
     31 	exit
     32 fi
     33 
     34 focus="$(xdotool getwindowfocus)"
     35 if [ "$focus" = "$scratchpad" ]; then
     36 	hide_window
     37 else
     38 	show_window
     39 fi
     40