X-Git-Url: https://ruderich.org/simon/gitweb/?p=config%2Fdotfiles.git;a=blobdiff_plain;f=x11%2Fherbstluftwm%2Fautostart;fp=x11%2Fherbstluftwm%2Fautostart;h=a9d530f2fc561be4160a55455907b77babc73561;hp=0000000000000000000000000000000000000000;hb=d11857eb2b9693235ed3531144a6b0a4d5cb1740;hpb=e0a76c26f9164e070166fcc62e1c287cc1033eef diff --git a/x11/herbstluftwm/autostart b/x11/herbstluftwm/autostart new file mode 100755 index 0000000..a9d530f --- /dev/null +++ b/x11/herbstluftwm/autostart @@ -0,0 +1,180 @@ +#!/bin/sh + +# Herbstluftm configuration file. + +# Copyright (C) 2014 Simon Ruderich +# +# This file is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this file. If not, see . + + +set -eu + + +hc() { + herbstclient "$@" +} +installed() { + type "$1" >/dev/null 2>&1 +} +# $1: timeout +notify() { + if installed dzen2; then + read x + printf '%s\n' "$x" | sed 's/\^/^^/g' \ + | dzen2 -fg blue -bg yellow -y 15 -h 30 -p "$1" & + elif installed xmessage; then + # Fallback solution, display first line of stdin. + read x + xmessage -timeout "$1" "$x" & + else + # Last way to send a "message", create a stupid window layout so I + # notice something is up and look at the logs. + hc fullscreen off + hc floating off + hc pseudotile off + hc split vertical 0.1 + hc unlock # or we might not see the changes + fi +} + +# Tell all clients the configuration file was reloaded. Should be the first +# command in the autostart file. +hc emit_hook reload + + +# KEY BINDINGS + +# Use Super (= "Windows") key as modifier which is used for all herbstluftwm +# key bindings. +mod=Mod4 + +# Remove all existing key bindings. +hc keyunbind --all + +# Basic key bindings. +hc keybind $mod-Shift-Return spawn urxvt +hc keybind $mod-Shift-c close +hc keybind $mod-q reload +hc keybind $mod-Shift-q quit +# Lock the screen. +hc keybind $mod-z spawn "$HOME/.xlockscreen" lock + +# Tag key bindings. Create tags 1 to 0 with bindings to switch and move +# windows to them. +hc rename default 1 2>/dev/null || true +for i in `seq 1 9` 0; do + hc add "$i" + hc keybind "$mod-$i" use "$i" + hc keybind "$mod-Shift-$i" move "$i" +done +# Switch to last active tag. +hc keybind $mod-b use_previous + +# Layouting key bindings. +hc keybind $mod-space cycle_layout 1 horizontal max # toggle these layouts +hc keybind $mod-u split vertical 0.5 +hc keybind $mod-o split horizontal 0.5 +hc keybind $mod-r remove # remove a split +# Change window state. +hc keybind $mod-f fullscreen toggle +# Reset fullscreen and layout. Just in case I get confused. +hc keybind $mod-Shift-space chain , fullscreen off , set_layout horizontal + +# Focus key bindings. +hc keybind $mod-h focus left +hc keybind $mod-j focus down +hc keybind $mod-k focus up +hc keybind $mod-l focus right +# Move windows. +hc keybind $mod-Shift-h shift left +hc keybind $mod-Shift-j shift down +hc keybind $mod-Shift-k shift up +hc keybind $mod-Shift-l shift right +# Swap top and bottom frame (only works with two frames). +hc keybind $mod-s chain , lock , rotate , rotate , unlock + + +# MOUSE BINDINGS + +# Remove all existing key bindings. +hc mouseunbind --all + + +# GENERAL SETTINGS + +# Necessary for Java so it recognizes herbstluftwm as tiling window manager. +hc set wmname LG3D +# Auto-detect new monitors. +hc set auto_detect_monitors 1 + + +# WINDOW and FRAME SETTINGS + +# No border for frames, only for windows. +hc set frame_border_width 0 +hc set window_border_width 1 +# No gaps between frames or windows. +hc set frame_gap 0 +hc set window_gap 0 +# Inactive window borders are black, almost invisible on my black screen. +# Active window borders are dark red. +hc set window_border_normal_color '#000000' +hc set window_border_active_color '#990000' +# Transparent background for empty frames. +hc set frame_bg_transparent 1 + +# Use vertical layout for windows in frames per default. +hc set default_frame_layout 1 # vertical + + +# LAYOUT + +# Run only on startup, not when reloading the config. Thanks to The-Compiler +# in #herbstluftwm on Freenode (2014-01-10 16:26 CET) for the idea to use +# environment variables. +if ! hc getenv HLWMRC_LOADED >/dev/null; then + hc setenv HLWMRC_LOADED 1 + + # Setup my layout: Vertical split with my main terminal window in the top + # frame, secondary windows in the bottom frame. + hc split vertical 0.5 +fi + + +# RULES + +# Remove all existing rules. +hc unrule --all + +# * Do not focus new clients (default). +# * Don't allow clients to toggle fullscreen via EWMH. +# * Move new windows to the frame at the bottom of the screen. +hc rule focus=off \ + ewmhrequests=off \ + index=1 + +# Focus important windows when they are opened. +hc rule instance=xmessage focus=on + +# Move Iceweasel to tag 2. +hc rule instance=Navigator class=Iceweasel tag=2 + + +# After everything is done, allow redrawing of the windows. +hc unlock + + +# To notify me if set -eu has terminated the script (then this part won't get +# executed). +echo 'hlwm restarted' | notify 1