From c4d4721c0ce65b9b74a8e681f77eede27a2f0b8d Mon Sep 17 00:00:00 2001 From: druckdev <63563978+druckdev@users.noreply.github.com> Date: Fri, 3 Jul 2020 02:51:05 +0200 Subject: [PATCH] Scratchpad-terminal changes Open the scratchpad-terminal in the same working directory as the current window. This makes sense since I use it for small and quick tasks that often need to take place in the same place. Start the terminal in a separate workspace before switching back so that the window does not break the workspaces layout or its content. The script has to wait shortly so that the window is "done" (made floating, sticky, etc.). This is a very dirty hack and should be replaced in the future. --- .config/i3/config | 2 +- .config/i3/scratchpad-terminal.sh | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.config/i3/config b/.config/i3/config index 26dd61a..76fe49b 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -220,7 +220,7 @@ for_window [class="st-256color" title="^scratchpad-terminal$"] \ # hide scratchpad-terminal again when restarting i3 exec_always i3-msg '[class="St" title="^scratchpad-terminal$"] scratchpad show' # show scratchpad-terminal or create one if none exists -bindsym $mod+comma exec ~/.config/i3/scratchpad-terminal.sh -s -c st-256color -n scratchpad-terminal -e st +bindsym $mod+comma exec ~/.config/i3/scratchpad-terminal.sh -s -c st-256color -n scratchpad-terminal -e 'st -d "$(xcwd)"' # hide scratchpad-terminal indepedent of where the focus sits bindsym $mod+Shift+comma exec ~/.config/i3/scratchpad-terminal.sh -h -c st-256color -n scratchpad-terminal diff --git a/.config/i3/scratchpad-terminal.sh b/.config/i3/scratchpad-terminal.sh index c028dd2..04245a2 100755 --- a/.config/i3/scratchpad-terminal.sh +++ b/.config/i3/scratchpad-terminal.sh @@ -42,9 +42,13 @@ fi if [ $SHOW ]; then if [ $EXIST_NOT ]; then # terminal does not exist yet - # WORKSPACE="$(i3-msg -t get_workspaces | jq '.[] | select(.focused==true).name' | tr -d '"')" - # i3-msg "workspace $W_NAME, exec env SCRATCHPAD_TERMINAL=1 $COMMAND, workspace $WORKSPACE" - env SCRATCHPAD_TERMINAL=1 $COMMAND + WORKSPACE="$(i3-msg -t get_workspaces | jq '.[] | select(.focused==true).name' | tr -d '"')" + i3-msg "workspace $W_NAME" + eval env SCRATCHPAD_TERMINAL=1 $COMMAND & + # Sleep for a very short time until the window is ready (floating, etc.) + # TODO: Dirty hack! Find something better. + sleep 0.1 + i3-msg "workspace $WORKSPACE" elif [ $HIDDEN ]; then # terminal is "hidden" in scratchpad i3-msg "[class=\"$W_CLASS\" title=\"^${W_NAME}$\"] scratchpad show"