Skip to content

Commented bar.sh #62

@Anachron

Description

@Anachron

Maybe this will help newcomers. If I made any mistake, feel free to comment!

#!/bin/bash

# Create a named pipe for howm config output
ff="/tmp/howm.fifo"

# Create a logfile for howm log output
logfile="/home/harvey/.config/howm/log.txt"

# Create the pipe, if not existing
[[ -p $ff ]] || mkfifo -m 666 "$ff"

# Create a few workspaces and store them into an array
ws=("term" "vim" "www" "chat" "media")

# Mapping for layouts and the numbers that come from howm
lay=("" "" "" "")

# Set background color mappings
mbg=("#333333" "#5F5F87" "#AFD7AF")
# Set foreground color mappings
mfg=("#DDDDDD" "#333333" "#333333")

# Set background color for bar (dzen)
bg="#333333"

# Read howm pipe as howmout variable
while read -t 10 -r howmout || true; do
    # Check the output for a format that we can use
    if [[ $howmout =~ ^(([[:digit:]]+:)+[[:digit:]]+ ?)+$ ]]; then
        unset r
        # Read all needed howm output to seperate variables (seperated by :)
        IFS=':' read -r m l w s c <<< "$howmout"
        # Set the foreground color using the mappings
        r+='^fg('"${mfg[$m]}"')'
        # Set the background color using the mappings
        r+='^bg('"${mbg[$m]}"')'
        # Display the layout symbol for the current workspace
        r+=" ${lay[$l]} | "
        # Display the workspace name of the current workspace
        r+="${ws[$w - 1]}"
        # Brace expansion 
        r="${r%::*}"
    fi
    # Display the collected bar string and additionally the date on the right side
    printf "%s%s\n" "$r" " | $(date +"%F %R") "
# Pass those things to dzen and display it with specific height, background color, font and more
done < "$ff" | dzen2 -h 20 -y -20 -ta r -bg "$bg" -fn "Inconsolata-dz:size=10" &

# pass output to fifo
/usr/bin/howm -c ~/.config/howm/howmrc 1> "$ff" 2> "$logfile"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions