Commit f476b293 authored by epsi sayidina's avatar epsi sayidina

herbstluftwm putting it all together

parent 46bf9e05
#!/usr/bin/env bash
# ------------------------------------------------------------------
#
# Description: unified config for herbstluftwm autostart
# Created by: Epsi Nurwijayadi <epsi.nurwijayadi@gmail.com)
#
# Source
# https://github.com/epsi-rns/dotfiles/tree/master/herbstluftwm/bash
#
# Blog
# http://epsi-rns.github.io/desktop/2017/05/01/herbstlustwm-modularized-overview.html
# http://epsi-rns.github.io/desktop/2017/05/02/herbstlustwm-modularized-bash.html
#
# ------------------------------------------------------------------
DIR=$(dirname "$0")
. ${DIR}/gmc.sh
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# config
# https://www.gnu.org/software/bash/manual/bashref.html#Brace-Expansion
# `seq 10` 0, or $(seq 10)
tag_names=( {1..9} )
tag_keys=( {1..9} 0 )
# keybindings
# if you have a super key you will be much happier with Mod set to Mod4
# Mod=Mod1 # Use alt as the main modifier
# Alt=Mod1
# Mod=Mod4 # Use the super key as the main modifier
# Modifier variables
s=Shift
c=Control
m=Mod4
a=Mod1
# resizing frames
resizestep=0.05
declare -A keybinds=(
# session
["$m-$s-q"]='quit'
["$m-$s-r"]='reload'
["$m-$s-c"]='close'
# use your $TERMINAL with xterm as fallback
["$m-Return"]="spawn ${TERMINAL:-xfce4-terminal}"
# epsi
["$m-d"]='spawn dmenu_run_hlwm'
["$m-$s-d"]='spawn rofi -show run -opacity 90'
["$m-$s-x"]='spawn oblogout'
# basic movement
# focusing clients
["$m-Left"]='focus left'
["$m-Down"]='focus down'
["$m-Up"]='focus up'
["$m-Right"]='focus right'
["$m-h"]='focus left'
["$m-j"]='focus down'
["$m-k"]='focus up'
["$m-l"]='focus right'
# moving clients
["$m-$s-Left"]='shift left'
["$m-$s-Down"]='shift down'
["$m-$s-Up"]='shift up'
["$m-$s-Right"]='shift right'
["$m-$s-h"]='shift left'
["$m-$s-j"]='shift down'
["$m-$s-k"]='shift up'
["$m-$s-l"]='shift right'
# splitting frames
# create an empty frame at the specified direction
["$m-u"]='split bottom 0.5'
["$m-o"]='split right 0.5'
# let the current frame explode into subframes
["$m-$c-space"]='split explode'
# resizing frames
["$m-$c-h"]="resize left +$resizestep"
["$m-$c-j"]="resize down +$resizestep"
["$m-$c-k"]="resize up +$resizestep"
["$m-$c-l"]="resize right +$resizestep"
["$m-$c-Left"]="resize left +$resizestep"
["$m-$c-Down"]="resize down +$resizestep"
["$m-$c-Up"]="resize up +$resizestep"
["$m-$c-Right"]="resize right +$resizestep"
# MPC
["$m-$a-h"]='spawn mpc toggle'
["$m-$a-t"]='spawn mpc prev'
["$m-$a-n"]='spawn mpc next'
)
# tags
declare -A tagskeybinds=(
# cycle through tags
["$m-period"]='use_index +1 --skip-visible'
["$m-comma"]='use_index -1 --skip-visible'
# layouting
["$m-r"]='remove'
["$m-s"]='floating toggle'
["$m-f"]='fullscreen toggle'
["$m-p"]='pseudotile toggle'
# focus
["$m-BackSpace"]='cycle_monitor'
["$m-Tab"]='cycle_all +1'
["$m-$s-Tab"]='cycle_all -1'
["$m-c"]='cycle'
["$m-i"]='jumpto urgent'
)
declare -A mousebinds=(
# mouse
["$m-Button1"]='move'
["$m-Button2"]='zoom'
["$m-Button3"]='resize'
)
# theme
declare -A attributes=(
["theme.tiling.reset"]='1'
["theme.floating.reset"]='1'
["theme.active.color"]="${color['red500']}"
["theme.normal.color"]="${color['grey200']}"
["theme.urgent.color"]="${color['pink500']}"
["theme.inner_width"]='0'
["theme.inner_color"]='black'
["theme.border_width"]='2'
["theme.floating.border_width"]='4'
["theme.floating.outer_width"]='1'
["theme.floating.outer_color"]='black'
["theme.active.inner_color"]='#3E4A00'
["theme.active.outer_color"]='#3E4A00'
["theme.background_color"]='#141414'
)
declare -A sets=(
["frame_border_active_color"]="${color['grey200']}"
["frame_bg_active_color"]="${color['yellow900']}"
["frame_border_normal_color"]="${color['grey50']}"
["frame_bg_normal_color"]="${color['red500']}"
["frame_border_width"]='0'
["always_show_frame"]='0'
["frame_bg_transparent"]='1'
["frame_transparent_width"]='2'
["frame_gap"]='20'
["window_gap"]='0'
["frame_padding"]='0'
["smart_window_surroundings"]='0'
["smart_frame_surroundings"]='1'
["mouse_recenter_gap"]='0'
)
# rules
declare -A rules=(
# normally focus new clients
["focus=on"]=''
# zero based array
["class=Firefox"]="tag=${tag_names[1]}"
["class=Chromium"]="tag=${tag_names[1]}"
["class=Geany"]="tag=${tag_names[2]}"
["class=Thunar"]="tag=${tag_names[3]}"
["class=gimp"]="tag=${tag_names[4]} pseudotile=on"
["class=Oblogout"]='fullscreen=on'
["class~'(.*[Rr]xvt.*|.*[Tt]erm|Konsole)'"]='focus=on'
# ["windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)'"]='pseudotile=on'
# ["windowtype='_NET_WM_WINDOW_TYPE_DIALOG'"]='focus=on'
["windowtype='_NET_WM_WINDOW_TYPE_DIALOG'"]='fullscreen=on'
# ["windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)'"]='manage=off'
)
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# helper
function hc() {
# http://www.thegeekstuff.com/2010/05/bash-shell-special-parameters/
herbstclient "$@"
}
function do_config()
{
local command="${1}"
shift
# associative array hack
eval "declare -A hash="${1#*=}
# loop over hash
for key in "${!hash[@]}"; do
local value=${hash[$key]}
hc $command $key $value
# uncomment to debug in terminal
# echo $command $key $value
done
}
function set_tags_with_name() {
hc rename default "${tag_names[0]}" 2>/dev/null || true
for index in ${!tag_names[@]} ; do
hc add "${tag_names[$index]}"
# uncomment to debug in terminal
# echo $index
local key="${tag_keys[$index]}"
if ! [ -z "$key" ] ; then
hc keybind "$m-$key" use_index "$index"
hc keybind "$m-Shift-$key" move_index "$index"
fi
done
}
# I don't understand what this is
function bind_cycle_layout() {
# The following cycles through the available layouts
# within a frame, but skips layouts, if the layout change
# wouldn't affect the actual window positions.
# I.e. if there are two windows within a frame,
# the grid layout is skipped.
hc keybind $m-space \
or , and . compare tags.focus.curframe_wcount = 2 \
. cycle_layout +1 vertical horizontal max vertical grid \
, cycle_layout +1
}
# do multi monitor setup here, e.g.:
# hc set_monitors 1280x1024+0+0 1280x1024+1280+0
# or simply:
# hc detect_monitors
function do_panel() {
local panel=$(dirname "$0")/panel-lemonbar.sh
[ -x "$panel" ] || panel=/etc/xdg/herbstluftwm/panel.sh
for monitor in $(herbstclient list_monitors | cut -d: -f1) ; do
# start it on each monitor
"$panel" $monitor &
done
}
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# load on startup
startup_run() {
command="silent new_attr bool my_not_first_autostart"
if hc $command ; then
# non windowed app
compton &
dunst &
parcellite &
nitrogen --restore &
mpd &
# windowed app
xfce4-terminal &
sleep 1 && firefox &
sleep 2 && geany &
sleep 2 && thunar &
fi
}
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# main
# background before wallpaper
xsetroot -solid "${color['blue500']}"
# Read the manual in $ man herbstluftwm
hc emit_hook reload
# gap counter
echo 35 > /tmp/herbstluftwm-gap
# do not repaint until unlock
hc lock
# standard
# remove all existing keybindings
hc keyunbind --all
hc mouseunbind --all
hc unrule -F
set_tags_with_name
# do hash config
# hack associative array function argument passing using declare -p
do_config 'keybind' "$(declare -p keybinds)"
do_config 'keybind' "$(declare -p tagskeybinds)"
do_config 'mousebind' "$(declare -p mousebinds)"
do_config 'attr' "$(declare -p attributes)"
do_config 'set' "$(declare -p sets)"
do_config 'rule' "$(declare -p rules)"
# avoid tilde problem, not using helper
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' pseudotile=on
# finishing, some extra miles
# I'm not sure what in this is
#bind_cycle_layout
# example of custom layout
layout='(split horizontal:0.5:0 '
layout+='(clients vertical:0) (clients vertical:0))'
hc load ${tag_names[0]} "$layout"
# tag number 5
hc floating 5 on
# hc set tree_style '╾│ ├└╼─┐'
hc set tree_style '⊙│ ├╰»─╮'
# unlock, just to be sure
hc unlock
# launch statusbar panel (e.g. dzen2 or lemonbar)
do_panel
# load on startup
startup_run
#!/usr/bin/env bash
# This is a compact config for herbstluftwm tags in dzen2 statusbar
# ------------------------------------------------------------------
#
# Description: unified config for herbstluftwm dzen2 statusbar
# Created by: Epsi Nurwijayadi <epsi.nurwijayadi@gmail.com)
#
# Source
# https://github.com/epsi-rns/dotfiles/tree/master/standalone/dzen2-hlwm/bash
#
# Blog
# http://epsi-rns.github.io/desktop/2017/06/11/herbstlustwm-event-idle-overview.html
# http://epsi-rns.github.io/desktop/2017/06/02/herbstlustwm-tag-status-bash.html
# http://epsi-rns.github.io/desktop/2017/06/12/herbstlustwm-event-idle-bash.html
#
# ------------------------------------------------------------------
# libraries
......
#!/usr/bin/env bash
# This is a compact config for herbstluftwm tags in lemonbar
# ------------------------------------------------------------------
#
# Description: unified config for herbstluftwm lemonbar
# Created by: Epsi Nurwijayadi <epsi.nurwijayadi@gmail.com)
#
# Source
# https://github.com/epsi-rns/dotfiles/tree/master/standalone/lemon-hlwm/bash
#
# Blog
# http://epsi-rns.github.io/desktop/2017/06/11/herbstlustwm-event-idle-overview.html
# http://epsi-rns.github.io/desktop/2017/06/02/herbstlustwm-tag-status-bash.html
# http://epsi-rns.github.io/desktop/2017/06/12/herbstlustwm-event-idle-bash.html
#
# ------------------------------------------------------------------
# libraries
......
-- vim: ts=4 sw=4 noet ai cindent syntax=lua
-- ------------------------------------------------------------------
--
-- Description: unified config for standalone conky dzen2 statusbar
-- Created by: Epsi Nurwijayadi <epsi.nurwijayadi@gmail.com)
--
-- Source
-- https://github.com/epsi-rns/dotfiles/tree/master/standalone/dzen2/conky
--
-- Blog
-- http://epsi-rns.github.io/desktop/2017/04/11/standalone-dzen2-conky.html
--
-- ------------------------------------------------------------------
--[[
Conky, a system monitor, based on torsmo
]]
......@@ -316,8 +329,8 @@ enabled = ''
.. parts.memory()
.. parts.cpu0()
.. parts.cputemp()
.. parts.ssid()
.. parts.network()
-- .. parts.ssid()
-- .. parts.network()
.. helper.separator()
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
......
-- vim: ts=4 sw=4 noet ai cindent syntax=lua
-- ------------------------------------------------------------------
--
-- Description: unified config for standalone conky lemonbar
-- Created by: Epsi Nurwijayadi <epsi.nurwijayadi@gmail.com)
--
-- Source
-- https://github.com/epsi-rns/dotfiles/tree/master/standalone/lemon/conky
--
-- Blog
-- http://epsi-rns.github.io/desktop/2017/04/14/standalone-lemonbar-conky.html
--
-- ------------------------------------------------------------------
--[[
Conky, a system monitor, based on torsmo
]]
......
......@@ -7,7 +7,7 @@ module MyHelper
) where
import System.Process
import System.Exit --
import System.Exit
import System.Directory
import System.IO
......@@ -22,6 +22,8 @@ type Pair = (String, String)
hc :: String -> IO ExitCode
hc arguments = system $ "herbstclient " ++ arguments
-- http://epsi-rns.github.io/code/2017/05/12/haskell-loop-with-map.html
-- IO action procedure
do_config :: String -> [Pair] -> IO ()
do_config command pairs = do
......
This diff is collapsed.
-- This is a compact config for herbstluftwm tags in dzen2 statusbar
-- ------------------------------------------------------------------
--
-- Description: unified config for herbstluftwm dzen2 statusbar
-- Created by: Epsi Nurwijayadi <epsi.nurwijayadi@gmail.com)
--
-- Source
-- https://github.com/epsi-rns/dotfiles/tree/master/standalone/dzen2-hlwm/haskell
--
-- Blog
-- http://epsi-rns.github.io/desktop/2017/06/11/herbstlustwm-event-idle-overview.html
-- http://epsi-rns.github.io/desktop/2017/06/08/herbstlustwm-tag-status-haskell.html
-- http://epsi-rns.github.io/desktop/2017/06/18/herbstlustwm-event-idle-haskell.html
--
-- ------------------------------------------------------------------
import System.Environment
import System.Process
......
-- This is a compact config for herbstluftwm tags in lemonbar
-- ------------------------------------------------------------------
--
-- Description: unified config for herbstluftwm lemonbar
-- Created by: Epsi Nurwijayadi <epsi.nurwijayadi@gmail.com)
--
-- Source
-- https://github.com/epsi-rns/dotfiles/tree/master/standalone/lemon-hlwm/haskell
--
-- Blog
-- http://epsi-rns.github.io/desktop/2017/06/11/herbstlustwm-event-idle-overview.html
-- http://epsi-rns.github.io/desktop/2017/06/08/herbstlustwm-tag-status-haskell.html
-- http://epsi-rns.github.io/desktop/2017/06/18/herbstlustwm-event-idle-haskell.html
--
-- ------------------------------------------------------------------
import System.Environment
import System.Process
......
This diff is collapsed.
......@@ -30,7 +30,7 @@ _M.tag_keys[9] = 0
-- if you have a super key you will be much happier with Mod set to Mod4
-- Mod=Mod1 -- Use alt as the main modifier
-- Alt=Mod1
-- Mod=Mod4 -- Use the super key as the main modifier
-- Mod=Mod4 -- Use the super key as the main modifier
-- Modifier variables
s = 'Shift';
......
#!/usr/bin/lua
-- This is a compact config for herbstluftwm tags in dzen2 statusbar
-- ------------------------------------------------------------------
--
-- Description: unified config for herbstluftwm dzen2 statusbar
-- Created by: Epsi Nurwijayadi <epsi.nurwijayadi@gmail.com)
--
-- Source
-- https://github.com/epsi-rns/dotfiles/tree/master/standalone/dzen2-hlwm/lua
--
-- Blog
-- http://epsi-rns.github.io/desktop/2017/06/11/herbstlustwm-event-idle-overview.html
-- http://epsi-rns.github.io/desktop/2017/06/07/herbstlustwm-tag-status-lua.html
-- http://epsi-rns.github.io/desktop/2017/06/17/herbstlustwm-event-idle-lua.html
--
-- ------------------------------------------------------------------
-- luaposix available in AUR
local posix = require "posix"
......@@ -8,7 +21,49 @@ local dirname = debug.getinfo(1).source:match("@?(.*/)")
package.path = package.path .. ';' .. dirname .. '?.lua;'
local gmc = require('.gmc')
local common = require('.common')
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- common
local common = {}
-- common functions
function common.sleep (n)
local t = os.clock()
while os.clock() - t <= n do
-- nothing
end
end
-- https://stackoverflow.com/questions/1426954/split-string-in-lua?rq=1
function common.split(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1 -- non zero based
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
-- http://lua-users.org/wiki/StringTrim
function common.trim1(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
-- https://stackoverflow.com/questions/33510736/check-if-array-contains-specific-value
function common.has_value (tab, val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- helper
......@@ -435,11 +490,11 @@ os.execute('herbstclient pad ' .. monitor .. ' '
-- run process in the background
local params_top = helper.get_params_top(monitor, panel_height)
pipehandler.detach_dzen2(monitor, params_top)
--local params_top = helper.get_params_top(monitor, panel_height)
--pipehandler.detach_dzen2(monitor, params_top)
local params_bottom = helper.get_params_bottom(monitor, panel_height)
pipehandler.detach_dzen2_conky(params_bottom)
-- optional transparency
pipehandler.detach_transset()
--pipehandler.detach_transset()
#!/usr/bin/lua
-- This is a compact config for herbstluftwm tags in lemonbar
-- ------------------------------------------------------------------
--
-- Description: unified config for herbstluftwm lemonbar
-- Created by: Epsi Nurwijayadi <epsi.nurwijayadi@gmail.com)
--
-- Source
-- https://github.com/epsi-rns/dotfiles/tree/master/standalone/lemon-hlwm/lua
--
-- Blog
-- http://epsi-rns.github.io/desktop/2017/06/11/herbstlustwm-event-idle-overview.html
-- http://epsi-rns.github.io/desktop/2017/06/07/herbstlustwm-tag-status-lua.html
-- http://epsi-rns.github.io/desktop/2017/06/17/herbstlustwm-event-idle-lua.html
--
-- ------------------------------------------------------------------
-- luaposix available in AUR
local posix = require "posix"
......@@ -8,7 +21,49 @@ local dirname = debug.getinfo(1).source:match("@?(.*/)")
package.path = package.path .. ';' .. dirname .. '?.lua;'
local gmc = require('.gmc')
local common = require('.common')
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- common
local common = {}
-- common functions
function common.sleep (n)
local t = os.clock()
while os.clock() - t <= n do
-- nothing
end
end
-- https://stackoverflow.com/questions/1426954/split-string-in-lua?rq=1
function common.split(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1 -- non zero based
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
-- http://lua-users.org/wiki/StringTrim
function common.trim1(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
-- https://stackoverflow.com/questions/33510736/check-if-array-contains-specific-value
function common.has_value (tab, val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end
-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
-- helper
......
#!/usr/bin/perl
# ------------------------------------------------------------------
#
# Description: unified config for herbstluftwm autostart
# Created by: Epsi Nurwijayadi <epsi.nurwijayadi@gmail.com)
#
# Source
# https://github.com/epsi-rns/dotfiles/tree/master/herbstluftwm/perl
#
# Blog
# http://epsi-rns.github.io/desktop/2017/05/01/herbstlustwm-modularized-overview.html
# http://epsi-rns.github.io/desktop/2017/05/03/herbstlustwm-modularized-perl.html
#
# ------------------------------------------------------------------
# See here for more sophisticated code
# https://github.com/ypnos/hlwm/blob/master/autostart
use warnings;
use strict;
use File::Basename;
use lib dirname(__FILE__);
use gmc;
my @tag_names = (1..9);
my @tag_keys = (1..9, 0);
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
# config
# keybindings
# if you have a super key you will be much happier with Mod set to Mod4
# Mod=Mod1 # Use alt as the main modifier
# Alt=Mod1
# Mod=Mod4 # Use the super key as the main modifier
# Modifier variables
my $s = 'Shift';
my $c = 'Control';
my $m = 'Mod4';
my $a = 'Mod1';
# resizing frames
my $resizestep = 0.05;
my %keybinds = (
# session
"$m-$s-q" => 'quit',
"$m-$s-r" => 'reload',
"$m-$s-c" => 'close',
# use ymy $TERMINAL with xterm as fallback
"$m-Return" => 'spawn ${TERMINAL:-xfce4-terminal}',
# epsi
"$m-d" => 'spawn dmenu_run_hlwm',
"$m-$s-d" => 'spawn rofi -show run -opacity 90',
"$m-$s-x" => 'spawn oblogout',
# basic movement