From eaff767e63d4ef2419c4cc26a033207acc92d057 Mon Sep 17 00:00:00 2001 From: Von Random Date: Tue, 23 Jun 2015 10:30:55 +0300 Subject: [PATCH] firefox -> chromium and initial bspwm config (thanks fbt) --- bspwm/autostart | 4 + bspwm/bspmenu | 9 ++ bspwm/bspmenu_run | 5 + bspwm/bspmenu_url | 15 +++ bspwm/bsptf | 6 ++ bspwm/bsptl | 9 ++ bspwm/bspwmrc | 27 ++++++ bspwm/common | 44 +++++++++ bspwm/panel/panel | 199 +++++++++++++++++++++++++++++++++++++++ bspwm/panel/panel_status | 53 +++++++++++ bspwm/sxhkdrc | 72 ++++++++++++++ termite_config | 2 +- 12 files changed, 444 insertions(+), 1 deletion(-) create mode 100755 bspwm/autostart create mode 100755 bspwm/bspmenu create mode 100755 bspwm/bspmenu_run create mode 100755 bspwm/bspmenu_url create mode 100755 bspwm/bsptf create mode 100755 bspwm/bsptl create mode 100755 bspwm/bspwmrc create mode 100755 bspwm/common create mode 100755 bspwm/panel/panel create mode 100755 bspwm/panel/panel_status create mode 100644 bspwm/sxhkdrc diff --git a/bspwm/autostart b/bspwm/autostart new file mode 100755 index 0000000..b074b1e --- /dev/null +++ b/bspwm/autostart @@ -0,0 +1,4 @@ +wallpaper="${HOME}/Pictures/wallpaper.png" +[[ -r "$wallpaper" ]] && feh --bg-center "$wallpaper" +xfce4-panel & +nm-applet & diff --git a/bspwm/bspmenu b/bspwm/bspmenu new file mode 100755 index 0000000..8509f40 --- /dev/null +++ b/bspwm/bspmenu @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +source "$HOME/.config/bspwm/common" + +dmenu -fn "$fontspec" \ + -nb "#$colour_bg_normal" \ + -nf "#$colour_fg_normal" \ + -sb "#$colour_bg_focused" \ + "$@" diff --git a/bspwm/bspmenu_run b/bspwm/bspmenu_run new file mode 100755 index 0000000..a757cd8 --- /dev/null +++ b/bspwm/bspmenu_run @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +source "$HOME/.config/bspwm/common" + +dmenu_path | /home/von/.config/bspwm/bspmenu -p 'run' "$@" | ${SHELL:-"/bin/sh"} & diff --git a/bspwm/bspmenu_url b/bspwm/bspmenu_url new file mode 100755 index 0000000..fd8e485 --- /dev/null +++ b/bspwm/bspmenu_url @@ -0,0 +1,15 @@ +#!/bin/sh + +get_bookmarks() { + while read url title; do + echo "$url" + done < "$HOME/.config/bookmarks" +} + +main() { + uri=$(get_bookmarks | /home/von/.config/bspwm/bspmenu -p 'url' "$@") + [ "$uri" ] && { sx-open "$uri"; } + echo "$uri" +} + +main "$@" diff --git a/bspwm/bsptf b/bspwm/bsptf new file mode 100755 index 0000000..fe6c4ec --- /dev/null +++ b/bspwm/bsptf @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +source "$HOME/.config/bspwm/common" + +bspc desktop -t floating +bspc control --get-status > "$panel_fifo" diff --git a/bspwm/bsptl b/bspwm/bsptl new file mode 100755 index 0000000..8d4501c --- /dev/null +++ b/bspwm/bsptl @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +bsp_status=$( bspc control --get-status ) +layout="${bsp_status##*:}" + +case "$layout" in + LT) bspc desktop -l monocle;; + LM) bspc desktop -l tiled;; +esac diff --git a/bspwm/bspwmrc b/bspwm/bspwmrc new file mode 100755 index 0000000..314c4f1 --- /dev/null +++ b/bspwm/bspwmrc @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +source "$HOME/.config/bspwm/common" + +#xsetroot -cursor_name left_ptr + +bspc config focused_border_color "#$colour_bg_focused" +bspc config normal_border_color "#$colour_bg_normal" +bspc config urgent_border_color "#$colour_urgent" +bspc config focused_sticky_border_color "#$colour_sticky_focused" +bspc config top_padding "$panel_h" +bspc config border_width "$bspwm_border_width" +bspc config window_gap "$bspwm_window_gap" + +bspc config focus_follows_pointer 'true' +bspc config pointer_follows_monitor 'true' +bspc config split_ratio '0.50' +bspc config borderless_monocle 'true' +bspc config gapless_monocle 'true' +bspc config focus_by_distance 'true' +bspc config ignore_ewmh_focus 'true' +#bspc config initial_polarity 'second_child' + +bspc monitor -d 1 2 3 4 5 + +bspc rule -a Gimp desktop=^8 follow=on floating=on +bspc rule -a mpv floating=on diff --git a/bspwm/common b/bspwm/common new file mode 100755 index 0000000..b9bd49c --- /dev/null +++ b/bspwm/common @@ -0,0 +1,44 @@ +# vim: ft=sh +# common config +colour_fg_normal='f9f9f9' +colour_fg_focused=$colour_fg_normal +colour_bg_normal='2d2d2d' +colour_bg_focused='00612b' +#colour_fg_normal_alpha='00' +#colour_fg_focused_alpha=$colour_fg_normal_alpha +#colour_bg_normal_alpha='00' +#colour_bg_focused_alpha='00' + +colour_urgent='610000' +colour_sticky_focused='030061' + +xset +fp /home/von/.fonts/terminus/PCF +fontspec='-*-terminus-medium-*-normal-*-14-*-*-*-*-*-iso10646-*' +font_bold='-*-terminus-bold-*-normal-*-14-*-*-*-*-*-iso10646-*' + +# bspwm config +bspwm_border_width='1' +bspwm_window_gap='3' + +# root win +#IFS='x' read -r root_win_w root_win_h < <( xwininfo -root | awk '/geometry/ { split($2,g,"+"); printf("%s", g[1]) }' ) + +# panel config +panel_bg_normal="${colour_bg_normal_alpha}${colour_bg_normal}" +panel_bg_focused="${colour_bg_focused_alpha}${colour_bg_focused}" +panel_fg_normal="${colour_fg_normal_alpha}${colour_fg_normal}" +panel_fg_focused="${colour_fg_focused_alpha}${colour_fg_focused}" +panel_fifo="/tmp/panel${DISPLAY}-fifo" +panel_h='18' +panel_w='100%' +panel_show_empty_tags=0 +# taskbar +panel_taskbar_enable=1 +panel_taskbar_max_length=160 +panel_taskbar_max_title=32 + +## dmenu in place of bar +#dmenu_w=$panel_w +#dmenu_h=$panel_h +#dmenu_x=$bspwm_window_gap +#dmenu_y=$bspwm_window_gap diff --git a/bspwm/panel/panel b/bspwm/panel/panel new file mode 100755 index 0000000..4fe558b --- /dev/null +++ b/bspwm/panel/panel @@ -0,0 +1,199 @@ +#!/usr/bin/env bash + +source "$HOME/.config/bspwm/common" + +cleanup() { + jobs=( $(jobs -p) ) + + if [[ "$jobs" ]]; then + kill "${jobs[@]}" + fi + + bspc config top_padding 0 +} + +get_line() { + declare counter=0 line=$1 + + while read; do + if (( counter == line )); then + printf '%s\n' "$REPLY" + return 0 + fi + + (( counter++ )) + done +} + +parse_fifo_data() { + declare msg desktop_spec + declare -g win_name misc bspwm_status + + while read; do + case "$REPLY" in + cmd::*) + read -r cmd args <<< "${REPLY#cmd::}" + + case "$cmd" in + redraw) + printf 'Redraw triggered\n' + sleep 1 + printf '%s\n' "$msg" + ;; + respawn) + printf 'Dying...\n' + sleep 1 + rexec + ;; + run) + $args + rexec + ;; + esac + ;; + updates::*) updates="${REPLY#*updates::}";; + date::*) date="${REPLY#*date::}";; + T*) + if (( panel_taskbar_enable )); then + unset win_title + unset taskbar taskbar_windows taskbar_length + + panel_taskbar_max_title_current=$panel_taskbar_max_title + + while read -r _ _ _ wid _ _ _ _ focus; do + if [[ "$wid" =~ [0-9]x[0-9A-F] ]]; then + if [[ "$focus" == '*' ]]; then + taskbar_windows+=( "$wid::F" ) + else + taskbar_windows+=( "$wid::u" ) + fi + fi + done < <( bspc query -T -d focused ) + + taskbar_windows_n="${#taskbar_windows[@]}" + + if (( taskbar_windows_n )); then + until (( taskbar_length )) && (( taskbar_length <= panel_taskbar_max_length )); do + unset taskbar + taskbar_length=$(( (taskbar_windows_n * 2) + 2 )) + + for w in "${taskbar_windows[@]}"; do + IFS='::' read -r wid _ state <<< "$w" + win_title=$( xtitle -f '%s' -t "${panel_taskbar_max_title_current}" "$wid" ) + win_title_length="${#win_title}" + + taskbar_length=$(( taskbar_length + win_title_length )) + + if [[ "$state" == 'F' ]]; then + taskbar+=" %{B#${panel_bg_focused}}%{F#${panel_bg_normal}}%{F-} ${win_title} %{B-}%{F#${panel_bg_focused}}%{F-}" + else + taskbar+=" %{A:bspc window -f ${wid}:} ${win_title} %{A}" + fi + done + + (( panel_taskbar_max_title_current-- )) + done + fi + else + win_title="${REPLY#*T}" + if [[ "$win_title" ]]; then + taskbar=" %{B#${panel_bg_focused}}%{F#${panel_bg_normal}}%{F-} ${win_title} %{B-}%{F#${panel_bg_focused}}%{F-}" + else + unset taskbar + fi + fi + ;; + WM*) + unset desktop_spec + IFS=':' read -a bspwm_status <<< "$REPLY" + + for i in "${bspwm_status[@]}"; do + if [[ "$i" =~ ^[oOfFuU].+ ]]; then + n="${i#*[oOfFuU]}" + + case "$i" in + O*|F*|U*) desktop_spec+="%{B#${panel_bg_focused}} $n %{B-}";; + u*) desktop_spec+="%{B#${colour_urgent}}%{A:bspc desktop -f $n:} $n %{A}%{B-}";; + o*) desktop_spec+="%{B-}%{A:bspc desktop -f $n:} $n %{A}";; + f*) + (( panel_show_empty_tags )) && { + desktop_spec+="%{B-} $n " + } + ;; + esac + fi + done + + read _ _ _ _ layout float _ < <( bspc query -T -d focused | get_line 1 ) + + if [[ "$float" == 'f' ]]; then + float_flag='f' + else + float_flag='' + fi + + case "$layout" in + T) layout_flag='t';; + M) layout_flag='m';; + esac + + desktop_spec+=" %{A:bsptl:}[${layout_flag}${float_flag}]%{A}" + ;; + esac + + msg="$desktop_spec" + + [[ "$taskbar" ]] && { msg+="$taskbar"; } + + msg+="%{r}%{F#${colour_bg_focused}}%{F-}%{B#${panel_bg_focused}} $updates $date " + msg+='%{B-}%{F-}' + + printf '%s\n' "$msg" + done < "$panel_fifo" +} + +misc_status() { + declare ip msg date + + while sleep 1; do + date=$( date +%A,\ %Y.%m.%d\ %H:%M:%S ) + msg="[ $date ]" + printf 'S:%s\n' "$msg" + done +} + +rexec() { + kill $(jobs -p) + exec "$0" +} + +main() { + trap 'cleanup' EXIT TERM INT + trap 'rexec' HUP + + [[ -e "$panel_fifo" ]] && { + rm "$panel_fifo" || { return 1; } + } + + mkfifo "$panel_fifo" + + if (( panel_taskbar_enable )); then + xtitle -s -t "$panel_taskbar_max_title" -f 'T%s' > "$panel_fifo" & + else + xtitle -s -f 'T%s' > "$panel_fifo" & + fi + + bspc control --subscribe > "$panel_fifo" & + /home/von/.config/bspwm/panel/panel_status & + + bspc config top_padding "$(( panel_h + bspwm_window_gap ))" + + parse_fifo_data | lemonbar -g "1280x16+0+0" \ + -f "$fontspec" \ + -f "$font_bold" \ + -F "#${panel_fg_normal}" \ + -B "#${panel_bg_normal}" | sh & + wait +} + +main diff --git a/bspwm/panel/panel_status b/bspwm/panel/panel_status new file mode 100755 index 0000000..3be41d5 --- /dev/null +++ b/bspwm/panel/panel_status @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +source "$HOME/.config/bspwm/common" + +status::date() { + while true; do + printf 'date::%%{T2}%s%%{T}\n' "$(date '+%a %d %H:%M')" + sleep 1 + done +} + +status::updates() { + declare pkgs + + while true; do + pkgs=( $(pacman -Qqu) ) + pkgs_n=${#pkgs[@]} + + if (( pkgs_n )); then + printf 'updates::[ Updates: %s ]\n' "${#pkgs[@]}" + else + printf 'updates::[ No updates ]\n' + fi + + sleep 5 + done +} + +cleanup() { + kill $(jobs -p) +} + +rexec() { + kill $(jobs -p) + exec "$0" +} + +main() { + declare msg date + + trap cleanup EXIT TERM INT + trap rexec HUP + + modules=( date ) + + for i in "${modules[@]}"; do + "status::${i}" > "$panel_fifo" & + done + + wait +} + +main diff --git a/bspwm/sxhkdrc b/bspwm/sxhkdrc new file mode 100644 index 0000000..1a24a43 --- /dev/null +++ b/bspwm/sxhkdrc @@ -0,0 +1,72 @@ +# +# bspwm hotkeys +# + +super + {_,shift + } w + bspc window {-c,-k} + +super + q + bspc window -t fullscreen + +super + {j,k} + bspc window -f {next,prev} + +control + {j,l} + bspc window -e {down,right} +32 + +control + {k,h} + bspc window -e {down,right} -32 + +super + space + bspc window -t floating + +super + Return + bspc window -s biggest + +super + {1-9} + bspc desktop -f {1-9} + +super + shift + {1-9} + bspc window -d {1-9} + +super + t + /home/von/.config/bspwm/bsptl + +super + f + /home/von/.config/bspwm/bsptf + +control + bracketright + bspc desktop -R 90 + +~button1 + bspc pointer -g focus + +super + button{1-3} + bspc pointer -g {move,resize_side,resize_corner} + +super + !button{1-3} + bspc pointer -t %i %i + +super + @button{1-3} + bspc pointer -u + +super + x + termite + +super + {r,u} + /home/von/.config/bspwm/bspmenu_{run,url} + +super + z + i3lock-extra -m pixelize ~/pics/lock.png + +Print + snap -f + +super + b + chameleon pics/wallpapers + +super + {Left,Up,Right,Down} + bspc window --presel {left,up,right,down} + +super + c + win-hd-center 1280x720 diff --git a/termite_config b/termite_config index 45888d5..a9ba502 100644 --- a/termite_config +++ b/termite_config @@ -13,7 +13,7 @@ search_wrap = true icon_name = terminal cursor_blink = off cursor_shape = block -browser = firefox +browser = chromium size_hints = false [colors]