[Shell] Personal dotfiles and scripts to deploy them.
Herbstluftwm autostart.
herbstluftwm-autostart.org
@@ -15,9 +15,10 @@
15
15
16
16
* Introduction
17
17
18
Removed:
This is my literate configuration for {{{hl}}}. It is a manual tiling
19
Removed:
window manager and has the particularity of being configured via the
20
Removed:
~herbstclient~ program.
18
Added:
This is my literate configuration for {{{hl}}} and other programs
19
Added:
started at the beginning of a graphical session. {{{hl}}} is a manual
20
Added:
tiling window manager and is configured via the ~herbstclient~
21
Added:
program.
21
22
22
23
#+begin_center
23
24
\Huge\textbf{Herbstluft}\\
@@ -28,41 +29,20 @@
28
29
* Early setup
29
30
30
31
31
Removed:
** Compositor
32
Removed:
33
Removed:
#+BEGIN_SRC shell
34
Removed:
killall picom
35
Removed:
picom &
36
Removed:
#+END_SRC
37
Removed:
38
Removed:
39
32
** Definitions
40
33
41
34
We begin by defining a shorthand name for the ~herbstclient~ program:
42
35
36
Added:
#+NAME: hc
43
37
#+BEGIN_SRC shell
44
38
hc() {
45
39
herbstclient "$@"
46
40
}
47
41
#+END_SRC
48
42
49
Removed:
Choice of Modkey. Mod1 is Alt, Mod4 is Super.
50
43
51
Removed:
#+BEGIN_SRC shell
52
Removed:
Mod=Mod4
53
Removed:
#+END_SRC
44
Added:
** Basic
54
45
55
Removed:
56
Removed:
** ~Plank~ dock
57
Removed:
58
Removed:
#+BEGIN_SRC shell
59
Removed:
killall plank
60
Removed:
plank &
61
Removed:
#+END_SRC
62
Removed:
63
Removed:
64
Removed:
** TODO Basic
65
Removed:
66
46
We make {{{hl}}} execute code associated with the ~reload~ hook.
67
47
68
48
#+BEGIN_SRC shell
@@ -84,7 +64,13 @@
84
64
hc keyunbind --all
85
65
#+END_SRC
86
66
67
Added:
Choice of Modkey. =Mod1= is =Alt=, =Mod4= is =Super=.
87
68
69
Added:
#+BEGIN_SRC shell
70
Added:
Mod=Mod4
71
Added:
#+END_SRC
72
Added:
73
Added:
88
74
** Basic interaction with {{{hl}}}
89
75
90
76
#+BEGIN_SRC shell
@@ -94,30 +80,35 @@
94
80
#+END_SRC
95
81
96
82
97
Removed:
** Open programs interactively
83
Added:
** Close focused window or remove frame
98
84
99
85
#+BEGIN_SRC shell
100
Removed:
hc keybind $Mod-d spawn dmenu_run
86
Added:
hc keybind $Mod-q close_or_remove
101
87
#+END_SRC
102
88
103
89
104
Removed:
** Close focused window or remove frame
90
Added:
** Application shortcuts
105
91
92
Added:
93
Added:
*** Menu
94
Added:
95
Added:
{{{hl}}} wrapper around dmenu.
96
Added:
106
97
#+BEGIN_SRC shell
107
Removed:
hc keybind $Mod-q close_or_remove
98
Added:
hc keybind $Mod-d spawn "/etc/xdg/herbstluftwm/dmenu_run_hlwm"
108
99
#+END_SRC
109
100
110
101
111
Removed:
** Spawn a terminal
102
Added:
*** Terminal
112
103
113
Removed:
We use our $TERMINAL with ~xfce4-terminal~ as fallback.
104
Added:
We use =st=.
114
105
115
106
#+BEGIN_SRC shell
116
Removed:
hc keybind $Mod-Return spawn "${TERMINAL:-xfce4-terminal}"
107
Added:
hc keybind $Mod-Return spawn "st"
117
108
#+END_SRC
118
109
119
110
120
Removed:
** Start common applications
111
Added:
*** TODO Emacs
121
112
122
113
We assign shortcuts to commonly used applications.
123
114
@@ -194,8 +185,8 @@
194
185
*** Basic definitions
195
186
196
187
#+BEGIN_SRC shell
197
Removed:
tag_names=( {1..9} )
198
Removed:
tag_keys=( {1..9} 0 )
188
Added:
tag_names=( {1..5} )
189
Added:
tag_keys=( {1..5} 0 )
199
190
200
191
hc rename default "${tag_names[0]}" || true
201
192
for i in "${!tag_names[@]}" ; do
@@ -242,7 +233,7 @@
242
233
#+END_SRC
243
234
244
235
245
Removed:
*** Mouse bindings
236
Added:
** Mouse bindings
246
237
247
238
#+BEGIN_SRC shell
248
239
hc mouseunbind --all
@@ -252,7 +243,7 @@
252
243
#+END_SRC
253
244
254
245
255
Removed:
*** Cycle the active screens
246
Added:
** Cycle the active screens
256
247
257
248
#+BEGIN_SRC shell
258
249
hc keybind $Mod-Tab cycle_all +1
@@ -266,7 +257,7 @@
266
257
#+END_SRC
267
258
268
259
269
Removed:
*** Jump to to next urgent program
260
Added:
** Jump to to next urgent program
270
261
271
262
Super useful when getting prompted for permissions in a browser on a
272
263
different tag!
@@ -278,15 +269,20 @@
278
269
279
270
* Theme
280
271
281
Removed:
282
Removed:
** Basic
283
Removed:
284
272
#+BEGIN_SRC shell
285
273
hc attr theme.tiling.reset 1
286
274
hc attr theme.floating.reset 1
287
275
#+END_SRC
288
276
289
277
278
Added:
** Colors
279
Added:
280
Added:
#+begin_src shell
281
Added:
color_main='#666611'
282
Added:
xsetroot -solid $color_main
283
Added:
#+end_src
284
Added:
285
Added:
290
286
** Frames
291
287
292
288
#+BEGIN_SRC shell
@@ -383,7 +379,6 @@
383
379
hc set smart_window_surroundings off
384
380
#+END_SRC
385
381
386
Removed:
387
382
#+BEGIN_SRC shell
388
383
hc set mouse_recenter_gap 0
389
384
#+END_SRC
@@ -417,45 +412,304 @@
417
412
#+END_SRC
418
413
419
414
420
Removed:
** Multi-monitor setup
415
Added:
* Other programs
421
416
422
Removed:
#+BEGIN_SRC shell
423
Removed:
# do multi monitor setup here, e.g.:
424
Removed:
# hc set_monitors 1280x1024+0+0 1280x1024+1280+0
425
Removed:
# or simply:
426
Removed:
# hc detect_monitors
427
Removed:
#+END_SRC
428
417
429
Removed:
430
418
** Panel
431
419
432
Removed:
So nice.
420
Added:
#+begin_src shell
421
Added:
xset +fp /home/blendux/.fonts/
422
Added:
kill $(pgrep --full "panel.sh")
423
Added:
bash ~/.config/herbstluftwm/panel.sh
424
Added:
#+end_src
433
425
426
Added:
This panel is adapted from the one provided by default by {{{hl}}},
427
Added:
located at [[file:/etc/xdg/herbstluftwm/panel.sh]].
434
428
435
Removed:
** TODO Vanilla shell panel
436
Removed:
# Add panel in here, literally
429
Added:
I'm using =lemonbar-xft=, which provides XFT support.
437
430
438
Removed:
#+BEGIN_SRC shell
431
Added:
#+begin_src shell :tangle no
432
Added:
font='-*-hack-medium-r-*-*-*-*-*-*-*-*-*-*'
433
Added:
font_xft='Hack'
434
Added:
# extract colors from hlwm and omit alpha-value
435
Added:
bgcolor=$(herbstclient get frame_border_normal_color|sed 's,^\(\#[0-9a-f]\{6\}\)[0-9a-f]\{2\}$,\1,')
436
Added:
selbg=$(herbstclient get window_border_active_color|sed 's,^\(\#[0-9a-f]\{6\}\)[0-9a-f]\{2\}$,\1,')
437
Added:
selfg='#101010'
439
438
440
Removed:
#+END_SRC
439
Added:
# Quick maffs
440
Added:
monitor_width=$(herbstclient monitor_rect 0 | awk '{ print $3 }')
441
Added:
monitor_height=$(herbstclient monitor_rect 0 | awk '{ print $4 }')
442
Added:
window_gap=$(herbstclient get window_gap)
443
Added:
let "bar_width = monitor_width - (2 * $window_gap)"
444
Added:
bar_height=42
445
Added:
offset_horizontal=$window_gap
446
Added:
offset_vertical=0
447
Added:
bar_dimensions=${bar_width}x${bar_height}+${offset_horizontal}+${offset_vertical}
441
448
449
Added:
450
Added:
hlwm_datetime_short () {
451
Added:
date +"%R | %F"
452
Added:
}
453
Added:
454
Added:
hlwm_datetime_long () {
455
Added:
date +"%A, %d %B %Y | %R"
456
Added:
}
457
Added:
458
Added:
hlwm_battery_status () {
459
Added:
acpi | awk -F', ' '{ print $3 }'
460
Added:
}
461
Added:
462
Added:
hlwm_battery_level () {
463
Added:
acpi | awk -F', ' '{ print $2 }'
464
Added:
}
465
Added:
466
Added:
(while true; do
467
Added:
echo "%{c}$(hlwm_datetime_short)%{r}$(hlwm_battery_status) $(hlwm_battery_level)"
468
Added:
sleep 1
469
Added:
done
470
Added:
) | lemonbar -f ${font_xft} -g $bar_dimensions # -B $selbg
471
Added:
#+end_src
472
Added:
473
Added:
#+RESULTS:
474
Added:
475
Added:
#+begin_src shell :tangle "~/.config/herbstluftwm/panel.sh"
476
Added:
quote() {
477
Added:
local q="$(printf '%q ' "$@")"
478
Added:
printf '%s' "${q% }"
479
Added:
}
480
Added:
481
Added:
if [[ -f /usr/lib/bash/sleep ]]; then
482
Added:
# load and enable 'sleep' builtin (does not support unit suffixes: h, m, s!)
483
Added:
# requires pkg 'bash-builtins' on debian; included in 'bash' on arch.
484
Added:
enable -f /usr/lib/bash/sleep sleep
485
Added:
fi
486
Added:
487
Added:
hc_quoted="$(quote "${herbstclient_command[@]:-herbstclient}")"
488
Added:
hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ;}
489
Added:
monitor=${1:-0}
490
Added:
geometry=( $(hc monitor_rect "$monitor") )
491
Added:
if [ -z "$geometry" ] ;then
492
Added:
echo "Invalid monitor $monitor"
493
Added:
exit 1
494
Added:
fi
495
Added:
# geometry has the format W H X Y
496
Added:
x=${geometry[0]}
497
Added:
y=${geometry[1]}
498
Added:
panel_width=${geometry[2]}
499
Added:
panel_height=32
500
Added:
# font="-*-fixed-medium-*-*-*-24-*-*-*-*-*-*-*"
501
Added:
font='-*-hack-medium-r-*-*-*-*-*-*-*-*-*-*'
502
Added:
# font='Hack:pixelsize=20'
503
Added:
# extract colors from hlwm and omit alpha-value
504
Added:
bgcolor=$(hc get frame_border_normal_color|sed 's,^\(\#[0-9a-f]\{6\}\)[0-9a-f]\{2\}$,\1,')
505
Added:
selbg=$(hc get window_border_active_color|sed 's,^\(\#[0-9a-f]\{6\}\)[0-9a-f]\{2\}$,\1,')
506
Added:
selfg='#101010'
507
Added:
508
Added:
####
509
Added:
# Try to find textwidth binary.
510
Added:
# In e.g. Ubuntu, this is named dzen2-textwidth.
511
Added:
if which textwidth &> /dev/null ; then
512
Added:
textwidth="textwidth";
513
Added:
elif which dzen2-textwidth &> /dev/null ; then
514
Added:
textwidth="dzen2-textwidth";
515
Added:
elif which xftwidth &> /dev/null ; then # For guix
516
Added:
textwidth="xftwidth";
517
Added:
else
518
Added:
echo "This script requires the textwidth tool of the dzen2 project."
519
Added:
exit 1
520
Added:
fi
521
Added:
####
522
Added:
# true if we are using the svn version of dzen2
523
Added:
# depending on version/distribution, this seems to have version strings like
524
Added:
# "dzen-" or "dzen-x.x.x-svn"
525
Added:
if dzen2 -v 2>&1 | head -n 1 | grep -q '^dzen-\([^,]*-svn\|\),'; then
526
Added:
dzen2_svn="true"
527
Added:
else
528
Added:
dzen2_svn=""
529
Added:
fi
530
Added:
531
Added:
if awk -Wv 2>/dev/null | head -1 | grep -q '^mawk'; then
532
Added:
# mawk needs "-W interactive" to line-buffer stdout correctly
533
Added:
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593504
534
Added:
uniq_linebuffered() {
535
Added:
awk -W interactive '$0 != l { print ; l=$0 ; fflush(); }' "$@"
536
Added:
}
537
Added:
else
538
Added:
# other awk versions (e.g. gawk) issue a warning with "-W interactive", so
539
Added:
# we don't want to use it there.
540
Added:
uniq_linebuffered() {
541
Added:
awk '$0 != l { print ; l=$0 ; fflush(); }' "$@"
542
Added:
}
543
Added:
fi
544
Added:
545
Added:
hc pad $monitor $panel_height
546
Added:
547
Added:
{
548
Added:
### Event generator ###
549
Added:
# based on different input data (mpc, date, hlwm hooks, ...) this generates events, formed like this:
550
Added:
# <eventname>\t<data> [...]
551
Added:
# e.g.
552
Added:
# date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29
553
Added:
554
Added:
#mpc idleloop player &
555
Added:
while true ; do
556
Added:
# output is checked once a second, but a "date" event is only
557
Added:
# generated if the output changed compared to the previous run.
558
Added:
printf 'date\t^fg(#efefef)%(%H:%M)T^fg(#909090), %(%Y-%m)T-^fg(#efefef)%(%d)T\n'
559
Added:
sleep 1 || break
560
Added:
done > >(uniq_linebuffered) &
561
Added:
childpid=$!
562
Added:
hc --idle
563
Added:
kill $childpid
564
Added:
} 2> /dev/null | {
565
Added:
IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)"
566
Added:
visible=true
567
Added:
date=""
568
Added:
windowtitle=""
569
Added:
while true ; do
570
Added:
571
Added:
### Output ###
572
Added:
# This part prints dzen data based on the _previous_ data handling run,
573
Added:
# and then waits for the next event to happen.
574
Added:
575
Added:
separator="^bg()^fg($selbg)|"
576
Added:
# draw tags
577
Added:
for i in "${tags[@]}" ; do
578
Added:
case ${i:0:1} in
579
Added:
'#')
580
Added:
echo -n "^bg($selbg)^fg($selfg)"
581
Added:
;;
582
Added:
'+')
583
Added:
echo -n "^bg(#9CA668)^fg(#141414)"
584
Added:
;;
585
Added:
':')
586
Added:
echo -n "^bg()^fg(#ffffff)"
587
Added:
;;
588
Added:
'!')
589
Added:
echo -n "^bg(#FF0675)^fg(#141414)"
590
Added:
;;
591
Added:
,*)
592
Added:
echo -n "^bg()^fg(#ababab)"
593
Added:
;;
594
Added:
esac
595
Added:
if [ ! -z "$dzen2_svn" ] ; then
596
Added:
# clickable tags if using SVN dzen
597
Added:
echo -n "^ca(1,$hc_quoted focus_monitor \"$monitor\" && "
598
Added:
echo -n "$hc_quoted use \"${i:1}\") ${i:1} ^ca()"
599
Added:
else
600
Added:
# non-clickable tags if using older dzen
601
Added:
echo -n " ${i:1} "
602
Added:
fi
603
Added:
done
604
Added:
echo -n "$separator"
605
Added:
echo -n "^bg()^fg() ${windowtitle//^/^^}"
606
Added:
# small adjustments
607
Added:
right="$separator^bg() $date $separator"
608
Added:
right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g')
609
Added:
# get width of right aligned text.. and add some space..
610
Added:
width=$($textwidth "$font" "$right_text_only ")
611
Added:
echo -n "^pa($(($panel_width - $width)))$right"
612
Added:
echo
613
Added:
614
Added:
### Data handling ###
615
Added:
# This part handles the events generated in the event loop, and sets
616
Added:
# internal variables based on them. The event and its arguments are
617
Added:
# read into the array cmd, then action is taken depending on the event
618
Added:
# name.
619
Added:
# "Special" events (quit_panel/togglehidepanel/reload) are also handled
620
Added:
# here.
621
Added:
622
Added:
# wait for next event
623
Added:
IFS=$'\t' read -ra cmd || break
624
Added:
# find out event origin
625
Added:
case "${cmd[0]}" in
626
Added:
tag*)
627
Added:
#echo "resetting tags" >&2
628
Added:
IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)"
629
Added:
;;
630
Added:
date)
631
Added:
#echo "resetting date" >&2
632
Added:
date="${cmd[@]:1}"
633
Added:
;;
634
Added:
quit_panel)
635
Added:
exit
636
Added:
;;
637
Added:
togglehidepanel)
638
Added:
currentmonidx=$(hc list_monitors | sed -n '/\[FOCUS\]$/s/:.*//p')
639
Added:
if [ "${cmd[1]}" -ne "$monitor" ] ; then
640
Added:
continue
641
Added:
fi
642
Added:
if [ "${cmd[1]}" = "current" ] && [ "$currentmonidx" -ne "$monitor" ] ; then
643
Added:
continue
644
Added:
fi
645
Added:
echo "^togglehide()"
646
Added:
if $visible ; then
647
Added:
visible=false
648
Added:
hc pad $monitor 0
649
Added:
else
650
Added:
visible=true
651
Added:
hc pad $monitor $panel_height
652
Added:
fi
653
Added:
;;
654
Added:
reload)
655
Added:
exit
656
Added:
;;
657
Added:
focus_changed|window_title_changed)
658
Added:
windowtitle="${cmd[@]:2}"
659
Added:
;;
660
Added:
#player)
661
Added:
# ;;
662
Added:
esac
663
Added:
done
664
Added:
665
Added:
### dzen2 ###
666
Added:
# After the data is gathered and processed, the output of the previous block
667
Added:
# gets piped to dzen2.
668
Added:
669
Added:
} | dzen2 -w $panel_width -x $x -y $y -fn "$font" -h $panel_height \
670
Added:
-e "button3=;button4=exec:$hc_quoted use_index -1;button5=exec:$hc_quoted use_index +1" \
671
Added:
-ta l -bg "$bgcolor" -fg '#efefef'
672
Added:
#+end_src
673
Added:
674
Added:
675
Added:
** Dock
676
Added:
442
677
#+BEGIN_SRC shell
443
Removed:
panel=~/.config/herbstluftwm/panel.sh
444
Removed:
[ -x "$panel" ] || panel=/etc/xdg/herbstluftwm/panel.sh
445
Removed:
for monitor in $(hc list_monitors | cut -d: -f1) ; do
446
Removed:
# start it on each monitor
447
Removed:
"$panel" "$monitor" &
448
Removed:
done
678
Added:
if [ $(pgrep plank) ]
679
Added:
then
680
Added:
pkill plank
681
Added:
else
682
Added:
plank &
683
Added:
fi
449
684
#+END_SRC
450
685
451
686
452
Removed:
** COMMENT Xmobar
687
Added:
** System information
453
688
454
Removed:
#+BEGIN_SRC shell
455
Removed:
killall xmobar
689
Added:
#+begin_src shell
690
Added:
if [ $(pgrep conky) ]
691
Added:
then
692
Added:
pkill conky
693
Added:
else
694
Added:
conky &
695
Added:
fi
696
Added:
#+end_src
456
697
457
Removed:
for monitor in $(hc list_monitors | cut -d: -f1) ; do
458
Removed:
# start it on each monitor
459
Removed:
xmobar &
460
Removed:
done
698
Added:
699
Added:
** Compositor
700
Added:
701
Added:
#+BEGIN_SRC shell
702
Added:
if [ $(pgrep picom) ]
703
Added:
then
704
Added:
pkill picom
705
Added:
else
706
Added:
picom &
707
Added:
fi
461
708
#+END_SRC
709
Added:
710
Added:
711
Added:
** TODO Desktop Background
712
Added:
713
Added:
#+begin_src shell
714
Added:
~/.fehbg &
715
Added:
#+end_src