Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commented bar.sh #62

Open
Anachron opened this issue Feb 24, 2016 · 2 comments
Open

Commented bar.sh #62

Anachron opened this issue Feb 24, 2016 · 2 comments

Comments

@Anachron
Copy link

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"
@HarveyHunt
Copy link
Owner

Hey, thanks for commenting the script.

It'd be cool if you could send this as a PR aimed at the develop branch.

Note: As of 2115aa8 howm is no longer aware of modes - that functionality has been moved into sxhkd, so the script will need updating to reflect this.

@Anachron
Copy link
Author

Hey @HarveyHunt,

sure thing, I can do that!

I just realized you already updated the example accordingly:
https://github.com/HarveyHunt/howm/blob/develop/examples/bar.sh

So I will fix my version and do a PR later. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants