Use st as terminal

Switch from gnome-terminal to st (see fork on github).
Open new terminal by default in the same working-dir as current window.
Modify scratchpad-terminal to work with every terminal.
This commit is contained in:
2020-06-24 16:05:34 +02:00
parent 2c2baa7187
commit 31a4bc0768
3 changed files with 28 additions and 17 deletions

View File

@@ -33,7 +33,9 @@ floating_modifier $mod
# set $TERMINAL kitty
# bindsym $mod+Return exec i3-sensible-terminal
# bindsym $mod+Return exec kitty
bindsym $mod+Return exec gnome-terminal --hide-menubar
# bindsym $mod+Return exec gnome-terminal --hide-menubar
bindsym $mod+Return exec st -d "$(xcwd)"
bindsym $mod+Shift+Return exec st
# kill focused window
bindsym $mod+Shift+q kill
@@ -206,19 +208,22 @@ bindsym XF86RFKill exec --no-startup-id ~/.config/i3/airplane-mode-notify.sh
exec --no-startup-id compton -b
# scratchpad-terminal
for_window [class="Gnome-terminal" title="^scratchpad-terminal$"] \
for_window [class="st-256color" title="^scratchpad-terminal$"] \
move scratchpad, \
sticky enable, \
scratchpad show, \
resize set 1600 900, \
border none, \
move position center
# 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
bindsym $mod+comma exec ~/.config/i3/scratchpad-terminal.sh -s -c st-256color -n scratchpad-terminal -e st
# hide scratchpad-terminal indepedent of where the focus sits
bindsym $mod+Shift+comma exec ~/.config/i3/scratchpad-terminal.sh -h
bindsym $mod+Shift+comma exec ~/.config/i3/scratchpad-terminal.sh -h -c st-256color -n scratchpad-terminal
bindsym $mod+Shift+m move scratchpad
bindsym $mod+Shift+o scratchpad show
bindsym $mod+Shift+s [class="^Spotify$"] scratchpad show
bindsym $mod+Shift+t [class="^TelegramDesktop$"] scratchpad show

View File

@@ -2,50 +2,55 @@
exec >/dev/null
CLASS="Gnome-terminal"
NAME="scratchpad-terminal"
while getopts "hn:s" FLAGS; do
while getopts "c:e:hn:s" FLAGS; do
case "$FLAGS" in
c) W_CLASS="$OPTARG";;
e) COMMAND="$OPTARG";;
h) HIDE=1;;
n) NAME="$OPTARG";;
n) W_NAME="$OPTARG";;
s) SHOW=1;;
*) exit 1;;
esac
done
shift $(($OPTIND - 1 ))
[ -n "$W_CLASS" ] || return 1
[ -n "$W_NAME" ] || return 1
[ -z "$SHOW" ] || [ -n "$COMMAND" ] || return 1
TREE="$(i3-msg -t get_tree)"
if ! (echo "$TREE" | grep -Po "\"name\":\"${NAME}\".*?floating\":\"[^\"]*\"" \
if ! (echo "$TREE" | grep -Po "\"name\":\"${W_NAME}\".*?class\":\"$W_CLASS\".*?floating\":\"[^\"]*\"" \
| grep -q '"floating":"user_on"')
then
EXIST_NOT=1
elif (echo "$TREE" | grep -Po '"focused":true.*?name":"[^"]*"' \
| grep -q "\"name\":\"${NAME}\"")
| grep -q "\"name\":\"${W_NAME}\"")
then
FOCUS_ON_PAD=1
elif [ ! $EXIST_NOT ] && (echo "$TREE" | grep -Po '"output":"__i3".*?"name":"[^"]*"' \
| grep -q "\"name\":\"${NAME}\"")
| grep -q "\"name\":\"${W_NAME}\"")
then
HIDDEN=1
fi
if [ $HIDE ] && [ ! $EXIST_NOT ] && [ ! $HIDDEN ]; then
# There is a visible scratchpad-terminal that shall be hidden
i3-msg "[class=\"$CLASS\" title=\"^${NAME}$\"] scratchpad show"
i3-msg "[class=\"$W_CLASS\" title=\"^${W_NAME}$\"] scratchpad show"
exit 0
fi
if [ $SHOW ]; then
if [ $EXIST_NOT ]; then
# terminal does not exist yet
gnome-terminal --window-with-profile="$NAME" --hide-menubar
# 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
elif [ $HIDDEN ]; then
# terminal is "hidden" in scratchpad
i3-msg "[class=\"$CLASS\" title=\"^${NAME}$\"] scratchpad show"
i3-msg "[class=\"$W_CLASS\" title=\"^${W_NAME}$\"] scratchpad show"
elif [ ! $FOCUS_ON_PAD ]; then
# terminal is visible but focus lays somewhere else
i3-msg "[class=\"$CLASS\" title=\"^${NAME}$\"] scratchpad show, scratchpad show"
i3-msg "[class=\"$W_CLASS\" title=\"^${W_NAME}$\"] scratchpad show, scratchpad show"
fi
exit 0
fi

View File

@@ -1,7 +1,8 @@
## Author: druckdev
## Created 2018-11-23
# echo ${(pl.$LINES..\n.)}
# Set terminals title if this is a scratchpad-terminal
[ -z "$SCRATCHPAD_TERMINAL" ] || printf "\x1b\x5d\x30\x3bscratchpad-terminal\x07"
# Enable Powerlevel10k instant prompt. Should stay at the top of ~/.config/zsh/.zshrc.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then