i3: Update config

Divide config into different sections and move all relevant lines into
those.
Use the $TERMINAL variable wherever possible.
Cleanup some stuff and add a couple of comments.
Add vim modeline to indicate filetype.
Set the key repeat rate.
Ditch scratchpad-terminal.sh:
    The reason why I created that script was that I liked to have
    different bindings for showing and hiding the terminal. At this
    point it just brings too much overhead in a dirty way for a feature
    I do not really need. mod+space can still be used to toggle focus
    and with mod+comma the window is now shown/hidden from/to
    scratchpad.
Use a terminal flag to set the window name instead of using escape
sequences at the start of a new shell.
This commit is contained in:
2020-10-23 20:01:30 +02:00
parent 74436f2625
commit 84d861112a
3 changed files with 70 additions and 121 deletions

View File

@@ -1,3 +1,4 @@
# i3 Settings ##################################################################
set $mod Mod4
# This font is widely installed, provides lots of unicode glyphs, right-to-left
@@ -7,22 +8,24 @@ font pango:DejaVu Sans Mono 10
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
# 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 st -d "$(xcwd)"
bindsym $mod+Shift+Return exec st
default_border pixel 1
hide_edge_borders smart
set $TERMINAL st
# Keybindins ###################################################################
# Terminal
bindsym $mod+Return exec $TERMINAL -d "$(xcwd)"
bindsym $mod+Shift+Return exec $TERMINAL
# Program launcher
bindsym $mod+d exec rofi -show drun
bindsym $mod+Shift+d exec dmenu_run
# kill focused window
bindsym $mod+Shift+q kill
# start dmenu (a program launcher)
bindsym $mod+Shift+d exec dmenu_run
bindsym $mod+d exec rofi -show drun
# change focus
focus_wrapping no
bindsym $mod+h focus left
@@ -115,7 +118,7 @@ mode "resize" {
# Set window size to predefined values
# firefox anti fingerprinting
bindsym p resize set 1920 1080
# scratchpad default size
# scratchpad-terminal default size
bindsym s resize set 1600 900
# "fullscreen"
bindsym f resize set 3200 1770
@@ -132,16 +135,6 @@ mode "resize" {
bindsym $mod+r mode "resize"
exec_always --no-startup-id ~/.config/i3/monitor-setup.sh &
# Touchpad configuration
# Find touchpad: `xinput list`
# Find options: `xinput list-props $touchpad`
set $touchpad DLL082A:01 06CB:76AF Touchpad
exec xinput set-prop "$touchpad" "libinput Tapping Enabled" 1
exec xinput set-prop "$touchpad" "libinput Natural Scrolling Enabled" 1
exec xinput set-prop "$touchpad" "libinput Accel Speed" 0.45
# Brightness controls (/etc/X11/xorg.conf necessary)
bindsym XF86MonBrightnessDown exec xbacklight -dec 5
bindsym XF86MonBrightnessUp exec xbacklight -inc 5
@@ -151,45 +144,34 @@ bindsym XF86MonBrightnessUp exec xbacklight -inc 5
bindsym XF86AudioRaiseVolume exec --no-startup-id amixer -q -D pulse sset Master 5%+
bindsym XF86AudioLowerVolume exec --no-startup-id amixer -q -D pulse sset Master 5%-
bindsym XF86AudioMute exec --no-startup-id amixer -q -D pulse sset Master toggle-mute
# volume at startup
exec amixer -q -D pulse sset Master mute
default_border pixel 1
hide_edge_borders smart
# Power
# Lock
bindsym $mod+mod1+l exec xset s activate
# Start powermenu
bindsym $mod+p exec ~/.config/rofi/powermenu.sh &
exec --no-startup-id xss-lock -l ~/.config/xsecurelock/transfer-sleep-lock.sh &
# Wallpaper
exec_always feh --bg-scale --no-fehbg ~/Pictures/Wallpapers/wallpaper
# Notify when toggling airplane mode
bindsym XF86RFKill exec --no-startup-id ~/.config/i3/airplane-mode-notify.sh
# compositor for transparency and blur
exec --no-startup-id ~/.config/compositor/launch.sh
# 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.
# Pass current working directory of the focused window but escape spaces.
bindsym $mod+comma exec ~/.config/i3/scratchpad-terminal.sh -s -c st-256color -n scratchpad-terminal -e "st -A 0.45 -d $(xcwd | sed 's/ /\\\\ /g')"
# 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
bindsym $mod+Shift+m move scratchpad
bindsym $mod+Shift+o scratchpad show
# scratchpad-terminal
for_window [class="^$TERMINAL-256color$" title="^scratchpad-terminal$"] \
move scratchpad, \
scratchpad show, \
sticky enable, \
border none, \
resize set 1600 900, \
move position center
# Toggle the scratchpad-terminal or create a new one if none exists.
bindsym $mod+comma exec i3-msg '[class="^$TERMINAL-256color$" title="^scratchpad-terminal$"] scratchpad show' || $TERMINAL -A 0.45 -d "$(xcwd)" -c $TERMINAL-256color -t scratchpad-terminal
bindsym $mod+Shift+s [class="^Spotify$"] scratchpad show
for_window [class="^TelegramDesktop$"] \
move scratchpad, \
scratchpad show
bindsym $mod+Shift+t [class="^TelegramDesktop$"] scratchpad show
# screenshots
@@ -199,11 +181,39 @@ bindsym --release $mod+Print exec gnome-screenshot -a
# Zoom links in private browser
bindsym $mod+z exec ~/.local/bin/zoom-links
# Keyboard layout
# German layout without dead keys and escape and capslock switched.
# exec setxkbmap de nodeadkeys -option 'caps:swapescape'
# German layout without dead keys + custom keymap changes + Control_R is escape when pressed alone and shortly
exec /bin/sh -c "setxkbmap de nodeadkeys -option && xmodmap ~/.Xmodmap && xcape -t 250 -e 'Control_R=Escape'"
# Setup different stuff ########################################################
# Multi monitor support
exec_always --no-startup-id ~/.config/i3/monitor-setup.sh &
# Start locker
exec --no-startup-id xss-lock -l ~/.config/xsecurelock/transfer-sleep-lock.sh &
# Compositor for transparency and blur
exec --no-startup-id ~/.config/compositor/launch.sh
# Touchpad configuration
# Find touchpad: `xinput list`
# Find options: `xinput list-props $touchpad`
set $touchpad DLL082A:01 06CB:76AF Touchpad
exec xinput set-prop "$touchpad" "libinput Tapping Enabled" 1
exec xinput set-prop "$touchpad" "libinput Natural Scrolling Enabled" 1
exec xinput set-prop "$touchpad" "libinput Accel Speed" 0.45
# Keyboard Setup
# German layout without dead keys
exec setxkbmap de nodeadkeys -option
# Custom keymap (switches escape, control_r and caps_lock around)
exec xmodmap ~/.Xmodmap
# Control_R act as Escape when pressed alone and shortly
exec xcape -t 250 -e 'Control_R=Escape'
# Faster key repeat rate
exec xset r rate 500 25
# Muted at startup
exec amixer -q -D pulse sset Master mute
# Wallpaper
exec_always feh --bg-scale --no-fehbg ~/Pictures/Wallpapers/wallpaper
# Restore GNOME's settings
exec --no-startup-id /usr/libexec/gnome-settings-daemon-localeexec
@@ -215,5 +225,7 @@ exec --no-startup-id dconf write /org/gnome/settings-daemon/plugins/cursor/activ
exec --no-startup-id gnome-keyring-daemon --start
# Focus should not follow mouse
# This is sometimes usefull when picking colors on the screen in combination with deactivated dim
# This is sometimes useful when picking colors on the screen in combination with deactivated dim
# focus_follows_mouse no
# vim: ft=i3

View File

@@ -1,60 +0,0 @@
#!/bin/sh
exec >/dev/null
while getopts "c:e:hn:s" FLAGS; do
case "$FLAGS" in
c) W_CLASS="$OPTARG";;
e) COMMAND="$OPTARG";;
h) HIDE=1;;
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\":\"${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\":\"${W_NAME}\"")
then
FOCUS_ON_PAD=1
elif [ ! $EXIST_NOT ] && (echo "$TREE" | grep -Po '"output":"__i3".*?"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=\"$W_CLASS\" title=\"^${W_NAME}$\"] scratchpad show"
exit 0
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"
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"
elif [ ! $FOCUS_ON_PAD ]; then
# terminal is visible but focus lays somewhere else
i3-msg "[class=\"$W_CLASS\" title=\"^${W_NAME}$\"] scratchpad show, scratchpad show"
fi
exit 0
fi