djcev.com // dotfiles / autostart.fix


Git Repos / dotfiles / config / herbstluftwm / autostart.fix

Last commit to this repo was on 2021-12-13 at 16:05.

#!/bin/sh
#
# Copyright (c) 2015-2021, Cameron Vanderzanden. Available under the
# terms of the 2-clause BSD license. Please see the file "LICENSE" in
# the root dir of this repository for more information.
#
#- config/herbstluftwm/autostart 2015/01/06 cev, last updated 2021/12/08
#
# configuration script for herbstluftwm.
# Based on the standard/example script shipped with the wm, available at:
# /usr/local/etc/xdg/herbstluftwm/autostart or share/autostart of the
# herbstluftwm tarball. Also available at:
# https://github.com/herbstluftwm/herbstluftwm/blob/master/share/autostart

printf 'config/herbstluftwm/autostart: running...\n'
hc() { herbstclient "$@"; }
# not fast, but this script isn't executed often, so...
nameforidx() {
# let's abuse the field seperator.
idx=$1; shift; count=0; names=$@; zIFS="$IFS"; IFS=":"
for name in $names; do
count=$((count + 1))
if [ $count -eq $idx ]; then echo $name && break; fi
done
IFS="$zIFS" && return $count
}

hc emit_hook reload
hc keyunbind --all
mod=Super # capslock will be set to super below
thirds=0.75 # not really.

# set up tags. "tagnames" variable is a list of tag names seperated by colon.
cvert="clients vertical:0"
tagnames="F1:F2:F3:F4:F5:F6:F7:F8:F9"
tagi=1; tagcount="$(nameforidx 0 $tagnames; echo $?)"
hc rename default "$(nameforidx $tagi $tagnames)" 2>/dev/null || true
while [ $tagi -le $tagcount ]; do
tagname="$(nameforidx $tagi $tagnames)"
hc add "$tagname"
hc load "$tagname" "(clients max:0)"
hc keybind "$mod-F$tagi" use_index $(($tagi - 1))
hc keybind "$mod-Shift-F$tagi" move_index $(($tagi - 1))
tagi=$(($tagi + 1))
done

# keyboard bindings
hc keybind $mod-Shift-q quit
hc keybind $mod-Shift-r reload
hc keybind $mod-space spawn /usr/local/bin/jgmenu_run
hc keybind $mod-Return spawn xvt.sh -n
hc keybind $mod-Delete close
hc keybind $mod-End spawn picom-trans -c 85
hc keybind $mod-Home spawn picom-trans -c 100
hc keybind $mod-Page_Up spawn picom-trans -c +5
hc keybind $mod-Page_Down spawn picom-trans -c -- -5
hc keybind Pause spawn fix_clip.sh
hc keybind $mod-period use_index +1 --skip-visible
hc keybind $mod-comma use_index -1 --skip-visible
hc keybind $mod-BackSpace cycle_monitor
hc keybind $mod-m cycle_all +1
hc keybind $mod-Shift-m cycle_all -1
hc keybind $mod-c cycle +1
hc keybind $mod-Shift-c cycle -1
hc keybind $mod-n cycle +1
hc keybind $mod-Shift-n cycle -1
hc keybind $mod-i jumpto urgent
hc keybind $mod-Tab use_previous


# keyboard bindings / layouting
hc keybind $mod-r remove
hc keybind $mod-z cycle_layout
hc keybind $mod-u split vertical $thirds
hc keybind $mod-o split horizontal $thirds
hc keybind $mod-s floating toggle
hc keybind $mod-f fullscreen toggle
hc keybind $mod-p pseudotile toggle
hc keybind $mod-backslash rotate

# keyboard bindings / directional arrows, keypad arrows, keypad nums, hjkl
keys_left='Left KP_Left KP_4 h'
keys_down='Down KP_Down KP_2 j'
keys_up='Up KP_Up KP_8 k'
keys_right='Right KP_Right KP_6 l'
for keys in "$keys_left" "$keys_down" "$keys_up" "$keys_right"; do
dir=$(echo ${keys%%' '*} | tr '[:upper:]' '[:lower:]')
for key in $keys; do
hc keybind $mod-$key focus $dir
hc keybind $mod-Control-$key resize $dir +0.05
hc keybind $mod-Shift-$key shift $dir
hc keybind $mod-Mod1-$key spawn hc_swap.sh $dir
done
done

# common layouts
l_m="clients max:0"
l_h3="split vertical:0.333300:0"
l_h3335="split horizontal:0.33350:0"; l_h667="split horizontal:0.667000:0"
l_v="clients vertical:0"; l_v25="split vertical:0.250000:0"
l_v50="split vertical:0.500000:0"; l_v75="split vertical:0.750000:0"
l_v_lower="($l_v75 ($l_m) ($l_m))"
l_v_upper="($l_v25 ($l_m) ($l_m))"
l_v_three="($l_v75 ($l_v25 ($l_m) ($l_m)) ($l_m))"
l_h_left="(split horizontal:0.733000:0 ($l_m) ($l_v))"
l_h_right="(split horizontal:0.286:0 ($l_v) ($l_m))"
l_h_three="($l_hz3335 ($l_h667 ($l_v) ($l_m)) ($l_v))"
l_vh_1="($l_v75 ($l_h667 ($l_m) ($l_v)) ($l_m))"
l_vh_2="($l_v75 ($l_h667 ($l_m) ($l_v50 ($l_m) ($l_m))) ($l_m))"
l_vh_3="($l_v75 ($l_h667 ($l_m) ($l_h3 ($l_m) ($l_v50 ($l_m) ($l_m)))) ($l_m))"

# bindings for common layouts
hc keybind $mod-KP_0 load "($l_m)"
hc keybind $mod-KP_Insert load "($l_m)"
hc keybind $mod-KP_1 load "$l_v_lower"
hc keybind $mod-KP_End load "$l_v_lower"
hc keybind $mod-KP_2 load "$l_v_upper"
hc keybind $mod-KP_Down load "$l_v_upper"
hc keybind $mod-KP_3 load "$l_v_three"
hc keybind $mod-KP_Page_Down load "$l_v_three"
hc keybind $mod-KP_4 load "$l_h_left"
hc keybind $mod-KP_Left load "$l_h_left"
hc keybind $mod-KP_5 load "$l_h_three"
hc keybind $mod-KP_6 load "$l_h_right"
hc keybind $mod-KP_Right load "$l_h_right"
hc keybind $mod-KP_7 load "$l_vh_1"
hc keybind $mod-KP_HOME load "$l_vh_1"
hc keybind $mod-KP_8 load "$l_vh_2"
hc keybind $mod-KP_Up load "$l_vh_2"
hc keybind $mod-KP_9 load "$l_vh_3"
hc keybind $mod-KP_Page_Up load "$l_vh_3"

# preload some layouts
hc load "F1" "$l_h_right"
hc load "F4" "$l_h_left"
hc load "F5" "$l_v_three"

# mouse bindings
hc mouseunbind --all
hc mousebind $mod-Button1 move
hc mousebind $mod-Button2 zoom
hc mousebind $mod-Button3 resize

# settings / attributes
hc attr settings.always_show_frame 1
hc attr settings.auto_detect_panels 'false'
hc attr settings.default_frame_layout 2
hc attr settings.frame_bg_transparent 'false'
hc attr settings.frame_border_width 0
hc attr settings.frame_normal_opacity 0
hc attr settings.frame_active_opacity 0
hc attr settings.frame_gap 8
hc attr settings.frame_padding 0
hc attr settings.window_gap 0
hc attr settings.smart_window_surroundings 0
hc attr settings.smart_frame_surroundings 0
hc attr settings.mouse_recenter_gap 0
hc attr settings.focus_follows_mouse 0
hc attr settings.tree_style '*| +`--.'
hc attr theme.tiling.reset 0
hc attr theme.floating.reset 0
hc attr theme.border_width 8
hc attr theme.inner_width 0
hc attr theme.outer_width 0
hc attr theme.padding_top 0
hc attr theme.padding_left 0
hc attr theme.padding_bottom 0
hc attr theme.padding_right 0
hc attr theme.title_height 27
hc attr theme.title_font 'Inconsolata-24'

# colors
hc attr theme.background_color 'xDK0h'
hc attr theme.color 'xDK0s'
hc attr theme.outer_color 'xDK0h'
hc attr theme.title_color 'xDK4'
hc attr theme.active.background_color 'xDK1'
hc attr theme.active.color 'xDK2'
hc attr theme.active.outer_color 'xDK1'
hc attr theme.active.title_color 'xLT4'
hc attr theme.urgent.background_color 'xORNf'
hc attr theme.urgent.color 'xORNn'
hc attr theme.urgent.outer_color 'xORNf'
hc attr theme.urgent.title_color 'xDK0'
hc attr settings.frame_bg_normal_color 'xDK0h'
hc attr settings.frame_bg_active_color 'xDK0h'
hc attr settings.frame_border_normal_color 'xDK0'
hc attr settings.frame_border_active_color 'xDK2'

# rules
hc unrule -F
hc rule focus=off
hc rule class=mpv focus=off pseudotile=off
hc rule class=XConsole focus=off tag="$(nameforidx 7 $tagnames)" index=0
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off
# windows that should get focus. terminal emulators, image viewers, etc.
hc rule class=Alacritty focus=on
hc rule class=lximage-qt focus=on
hc rule class=qterminal focus=on
hc rule class=SDL_App focus=on floating=on
hc rule class=Sxiv focus=on
hc rule class=Vncviewer focus=on tag="$(nameforidx 6 $tagnames)" index=0
hc rule class=xterm-256color focus=on
hc rule class~'(.*[Rr]xvt.*|.*[Tt]erm|Konsole)' focus=on
hc rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on
# windows that should float.
hc rule class~'(.*[Ee][Xx][Ee])' floating=on
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' floating=on
# web browsers
hc rule class=Chromium-browser focus=off tag="$(nameforidx 8 $tagnames)"
hc rule class=Falkon focus=off tag="$(nameforidx 8 $tagnames)"
hc rule class=Navigator focus=off tag="$(nameforidx 8 $tagnames)"
hc rule class=QupZilla focus=off tag="$(nameforidx 8 $tagnames)"

# final setup
hc unlock
/usr/local/bin/tint2 &
hc pad 0 0 0 0 64 # zero out padding
printf 'config/herbstluftwm/autostart: ...complete\n'

Return to top of this page or return to the overview of this repository