158 lines
4.9 KiB
Bash
Executable file
158 lines
4.9 KiB
Bash
Executable file
#!/usr/bin/env zsh
|
|
|
|
machine=$(hostname)
|
|
|
|
## Helper functions:
|
|
|
|
# This simple function saves a lot of keystrokes when editing this
|
|
# configuration. Instead of typing "herbstluftwm" everywhere, I can
|
|
# just type "hc". This is part of the default configuration.
|
|
function hc() { herbstclient "$@"; }
|
|
|
|
# This function picks a random wallpaper from a list collection.
|
|
function random-wallpaper() {
|
|
local rootinfo=$(xwininfo -root)
|
|
local width=$(echo $rootinfo | grep 'Width:' | sed 's/.*Width: \([[:digit:]]\+\).*/\1/')
|
|
local height=$(echo $rootinfo | grep 'Height:' | sed 's/.*Height: \([[:digit:]]\+\).*/\1/')
|
|
|
|
find ~/pictures/wallpaper -type f \
|
|
\( -wholename "*/${width}x${height}/*" -o -wholename '*/patterns/*' \) \
|
|
-not -name '*.org' \
|
|
| shuf -n 1
|
|
}
|
|
|
|
# This function adds an attribute to a herbstluftwm tag that tells it
|
|
# which monitor it should appear on, in case I care. Usually I want
|
|
# Emacs and my terminal to always appear on my primary monitor, and
|
|
# Conkeror/Firefox on my secondary, I don't like it when they get
|
|
# switched.
|
|
function lock-tag-to-monitor() {
|
|
herbstclient chain \
|
|
, new_attr string tags.by-name."$1".my_monitor \
|
|
, set_attr tags.by-name."$1".my_monitor "$2"
|
|
}
|
|
|
|
## Reload hook:
|
|
|
|
# According to the herbstluftwm man page this hook is emitted so that
|
|
# daemons will know to quit and it should be emitted first thing.
|
|
hc emit_hook reload
|
|
|
|
## Background image:
|
|
|
|
# Set a random image as the desktop wallpaper.
|
|
wallpaper=$(random-wallpaper)
|
|
|
|
if ! hc attr my_wallpaper
|
|
then
|
|
hc new_attr string my_wallpaper
|
|
fi
|
|
|
|
feh --bg-tile "$wallpaper" && hc set_attr my_wallpaper "$wallpaper"
|
|
|
|
## Keybindings:
|
|
# Remove all existing keybindings so that when herbstluftwm is
|
|
# restarted, no keybindings get accidentally left active if they've
|
|
# been removed.
|
|
hc keyunbind --all
|
|
|
|
# Use the super key as the main modifier, Alt (Mod1) is used by too
|
|
# many other applications (Emacs and Zsh for example) to really be
|
|
# useful.
|
|
Mod=Mod4
|
|
|
|
# mouse
|
|
hc mouseunbind --all
|
|
hc mousebind $Mod-Button1 move
|
|
hc mousebind $Mod-Button2 zoom
|
|
hc mousebind $Mod-Button3 resize
|
|
|
|
# Change the default layout to fullscreen.
|
|
hc set default_frame_layout 2
|
|
|
|
## Tags:
|
|
tag_names=(dev games)
|
|
tag_indexes=({1..${#tag_names}})
|
|
tag_keys=(bracketleft braceleft braceright parenleft equal
|
|
asterisk parenright plus bracketright exclam)
|
|
|
|
hc rename default "${tag_names[1]}" || true
|
|
for i in $tag_indexes; do
|
|
hc add "${tag_names[$i]}"
|
|
done
|
|
|
|
# theme
|
|
hc attr theme.tiling.reset 1
|
|
hc attr theme.floating.reset 1
|
|
hc set frame_border_active_color '#3d3d3d'
|
|
hc set frame_border_normal_color '#222222'
|
|
hc set frame_bg_normal_color '#111111'
|
|
hc set frame_bg_active_color '#263f1f'
|
|
hc set frame_border_width 0
|
|
hc set window_border_width 2
|
|
hc set window_border_inner_width 0
|
|
hc set window_border_normal_color '#222222'
|
|
hc set window_border_active_color '#1f3f3f'
|
|
hc set window_border_inner_color '#111111'
|
|
hc set always_show_frame 0
|
|
hc set frame_gap 30
|
|
# Add overlapping window borders
|
|
hc set window_gap 30
|
|
hc set frame_padding -30
|
|
hc set frame_bg_transparent 1
|
|
|
|
hc set smart_window_surroundings 0
|
|
hc set smart_frame_surroundings 0
|
|
hc set mouse_recenter_gap 0
|
|
hc set swap_monitors_to_get_tag 0
|
|
hc set update_dragged_clients 1
|
|
|
|
# rules
|
|
hc unrule -F
|
|
hc rule focus=on # normally focus new clients
|
|
hc rule class=Emacs tag=dev index=01 switchtag=on hook=emacs
|
|
hc rule class~'URxvt|kitty' tag=dev index=1 switchtag=on hook=urxvt
|
|
hc rule class~'Conkeror|[Ff]irefox|Chromium' tag=dev index=00 switchtag=on
|
|
hc rule class=Pinentry pseudotile=on
|
|
hc rule class=Alsaplayer pseudotile=on
|
|
hc rule class=Gcr-prompter pseudotile=on
|
|
hc rule class=Steam title~'Steam Login|Steam Sign In' pseudotile=on
|
|
hc rule class=Steam title~'Steam - News .*' pseudotile=on
|
|
hc rule class= title=Steam pseudotile=on
|
|
hc rule class=xfreerdp floating=on tag=work index=0 switchtag=on
|
|
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' pseudotile=on
|
|
hc rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on
|
|
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off
|
|
hc rule class=pinball.exe pseudotile=on
|
|
|
|
# unlock, just to be sure
|
|
hc unlock
|
|
|
|
herbstclient set tree_style '╾│ ├└╼─┐'
|
|
|
|
hc pad 0 0 0 0 0
|
|
|
|
# Load layouts for the dev and web tags.
|
|
hc load web '(clients max:0)'
|
|
|
|
# Make sure the "Emacs" frame is selected.
|
|
hc focus_edge left
|
|
|
|
## Other configurations
|
|
|
|
# Load a machine-specific configuration if it exists.
|
|
[ -x "${HOME}/.config/herbstluftwm/machines/${machine}.sh" ] \
|
|
&& source "${HOME}/.config/herbstluftwm/machines/${machine}.sh"
|
|
|
|
# Load any other configuration files in
|
|
# $HOME/.config/herbstluftwm/autostart.d so other programs can
|
|
# configure parts of herbstluftwm to their needs (such as keybindings
|
|
# for Rofi).
|
|
if [ -d "${HOME}/.config/herbstluftwm/autostart.d" ]; then
|
|
for f in ${HOME}/.config/herbstluftwm/autostart.d/?*.sh; do
|
|
[ -x "$f" ] && source "$f"
|
|
done
|
|
unset f
|
|
fi
|
|
|
|
herd start polybar
|