Skip to content

Instantly share code, notes, and snippets.

@Kattjakt
Created September 2, 2014 17:36
Show Gist options
  • Select an option

  • Save Kattjakt/53300f13c5a7e124e818 to your computer and use it in GitHub Desktop.

Select an option

Save Kattjakt/53300f13c5a7e124e818 to your computer and use it in GitHub Desktop.

Revisions

  1. Kattjakt created this gist Sep 2, 2014.
    114 changes: 114 additions & 0 deletions gistfile1.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,114 @@
    .xinitrc:
    exec ~/.config/bspwm/init

    init:
    xsetroot -cursor_name left_ptr&
    exec bspwm -c ~/.config/bspwm/bspwmrc

    bspwmrc:
    bspc monitor -d 1 2 3 4 5
    bspc config top_padding 16
    bspc config border_width 2
    bspc config window_gap 16
    bspc config split_ratio 0.52
    bspc config borderless_monocle true
    bspc config gapless_monocle true

    sxhkd &
    exec ~/.config/bspwm/bar/bar

    panel_bar
    #! /bin/sh
    #
    # Example panel for LemonBoy's bar

    while read -r line ; do
    case $line in
    S*)
    # clock output
    sys_infos="\\br\\f7${line#?}"
    ;;
    T*)
    # xtitle output
    title="\\br\\f4${line#?}"
    ;;
    W*)
    # bspwm internal state
    wm_infos=""
    IFS=':'
    set -- ${line#?}
    while [ $# -gt 0 ] ; do
    item=$1
    name=${item#?}
    case $item in
    O*)
    # focused occupied desktop
    wm_infos="$wm_infos \\u3\\br\\fr${name}\\ur"
    ;;
    F*)
    # focused free desktop
    wm_infos="$wm_infos \\u4\\br\\f7${name}\\ur"
    ;;
    U*)
    # focused urgent desktop
    wm_infos="$wm_infos \\u9\\br\\fr${name}\\ur"
    ;;
    o*)
    # occupied desktop
    wm_infos="$wm_infos \\br\\fr${name}"
    ;;
    f*)
    # free desktop
    wm_infos="$wm_infos \\br\\f7${name}"
    ;;
    u*)
    # urgent desktop
    wm_infos="$wm_infos \\b1\\fr${name}"
    ;;
    L*)
    # layout
    layout=$(printf "%s" "${name}" | sed 's/\(.\).*/\U\1/')
    wm_infos="$wm_infos \\br\\f2$layout"
    ;;
    esac
    shift
    done
    ;;
    esac
    printf "%s\n" "\\l $wm_infos \\c $title \\r $sys_infos "
    done

    panel:
    #! /bin/sh

    if [ $(pgrep -cx panel) -gt 1 ] ; then
    printf "%s\n" "The panel is already running." >&2
    exit 1
    fi

    trap 'trap - TERM; kill 0' INT TERM QUIT EXIT

    flavor=${1:-bar}

    [ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
    mkfifo "$PANEL_FIFO"

    bspc config top_padding $PANEL_HEIGHT

    bspc control --subscribe > "$PANEL_FIFO" &
    xtitle -sf 'T%s' > "$PANEL_FIFO" &
    clock -sf 'S%a %H:%M' > "$PANEL_FIFO" &

    case "$flavor" in
    bar)
    cat "$PANEL_FIFO" | panel_bar | bar &
    ;;
    dzen2)
    . panel_colors
    FONT_FAMILY='DejaVu Sans'
    FONT_SIZE=11
    cat "$PANEL_FIFO" | panel_dzen2 -f "$FONT_FAMILY" -s "$FONT_SIZE" | dzen2 -h $PANEL_HEIGHT -dock -ta l -title-name panel -fn "${FONT_FAMILY}:pixelsize=${FONT_SIZE}" -fg "$COLOR_FOREGROUND" -bg "$COLOR_BACKGROUND" &
    ;;
    esac

    wait