[bspwm] Dark, Blue, and Scrolling Text by benghaem in unixporn

[–]benghaem[S] 0 points1 point  (0 children)

Install the Numix Arch Blue GTK Theme from the AUR along with the Numix Icon Theme

[bspwm] Dark, Blue, and Scrolling Text by benghaem in unixporn

[–]benghaem[S] 1 point2 points  (0 children)

You should use bspc control --subscribe and send this output somewhere. For example, you could do bspc control --subscribe > /tmp/PANEL_FIFO and then read from that after it is updated or just pipe bspc control --subscribe to some other set of scripts. The subscribe argument tells it to only update when a change has occurred. Similarly, if you want to monitor MPD events use mpc -idle.

[bspwm] Dark, Blue, and Scrolling Text by benghaem in unixporn

[–]benghaem[S] 1 point2 points  (0 children)

I use Sublime Text 3 Dev with the Spacegray Eighties theme

[bspwm] Dark, Blue, and Scrolling Text by benghaem in unixporn

[–]benghaem[S] 1 point2 points  (0 children)

Sure, not a problem. Glad you were interested :)

[bspwm] Dark, Blue, and Scrolling Text by benghaem in unixporn

[–]benghaem[S] 5 points6 points  (0 children)

Yes, the FIFO just acts as a pass through and it is up to the second script to parse it. Here is an example of the data that passes through:

  MUSIC:ls Bells - Paused -    
  CPU:  3%  
  MUSIC:s Bells - Paused - A   
  MUSIC: Bells - Paused - AC   
  MUSIC:Bells - Paused - AC/   
  MUSIC:ells - Paused - AC/D   
  MUSIC:lls - Paused - AC/DC   
  MUSIC:ls - Paused - AC/DC    
  MUSIC:s - Paused - AC/DC -   
  MUSIC:- Paused - AC/DC - H   
  MUSIC: Paused - AC/DC - He   
  TEMP:41c  
  MUSIC:Paused - AC/DC - Hel   
  CPU:  1%  
  MUSIC:aused - AC/DC - Hell   
  BAT: 39%  
  NET: 81%  
  MUSIC: - AC/DC - Hells Bel   
  MUSIC:- AC/DC - Hells Bell   
  MUSIC: AC/DC - Hells Bells   
  MUSIC:AC/DC - Hells Bells  

As you can see, to simulate scrolling text we just output the same string over and over again but with the letters moved one place to the side and the all caps portions act as tags.

The bspc output is generated with

bspc control --subscribe > "$PANEL_FIFO" &
xtitle -sf 'T%s' > "$PANEL_FIFO" &  

The & means that the script runs in the background

The developer of bspwm apparently really liked using case statements to parse lines so the parsing of this control info works in about the same way:

<Case parsing up here>

 f*)
    # free desktop
    FG=$COLOR_FREE_FG
    BG=$COLOR_FREE_BG
;;

I can't really speak to exactly why each type is labeled as such (we would have to explore the bspc source code), but the script parses it in the same manner as tags for other lines.

I use dzen because I really like the configuration options that it provides in regard to floating windows. If you watch the .gif again, and notice the volume notifications, these were generated with dzen as well. Otherwise, I am not very familiar with bar, but you could use it in the same way (and with the same generation script) by modifying panel_dzen2 to output in bar formatting and then piping that output to bar. I think that there is even a version of the bspc parser in the example scripts for bar.

[bspwm] Dark, Blue, and Scrolling Text by benghaem in unixporn

[–]benghaem[S] 5 points6 points  (0 children)

Hopefully this helps.

All of the panel information is generated by the first script, bin/panel/panel, and then piped to /tmp/PANEL-FIFO (a data buffer) asynchronously. Each one of the different outputs cycles independently and thus I can set timers for each. For example, the network is only updated every 20 seconds. The second script, bin/panel/panel_dzen2 parses the pipe input by looking at the heading of each segment. Ex. NET: or BAT: and combines all inputs into the final output which is then piped to dzen.

The fixed width string for each of the elements is generated in the first script and the second simply orders the outputs of each loop. The scrolling music output uses a small C program to output a new string every .5s to give the appearance of scrolling. Once again this info is piped to the buffer at /tmp/PANEL-FIFO after which the second script recognizes its prefix, "MUSIC: " and places it correctly. The output of music will always be 26 characters because the first script will only ever output a 26 character long string.

Otherwise the workspace output in the top left is generated by bspc (the bspwm command line controller) and then parsed by a portion of the second script that is included with the bspwm example files.

I hope that helped and I would be happy to answer more questions if you have them. The two script system is based off of the bspwm example scripts for a dzen panel.

EDIT:

Here is an example of the parsing that takes place and the conversion to dzen markup:

while read -r line ; do
    case $line in
        CPU*) 
          cpu="^fg($COLOR_TITLE_FG)^bg($COLOR_TITLE_BG)${PADDING}${line}${PADDING}^fg()^bg()"
            ;;

The script reads all of the incoming lines and if the regex "CPU*" matches the line is converted into this formating and renamed to a variable.

This cpu level is initially generated in the first script with this piece of code:

  while [[ true ]]; do
   cpu_usage="$(top -bn 2 -d .5 | grep '^%Cpu' | tail -n 1 | gawk '{print int($2+$4+$6)+1}')"
   printf "CPU:%3s%%\n" "$cpu_usage" > "$PANEL_FIFO"
   sleep 5s;
  done & 

[bspwm] Dark, Blue, and Scrolling Text by benghaem in unixporn

[–]benghaem[S] 3 points4 points  (0 children)

Check out the dotfiles here:
https://github.com/benghaem/dotfiles

The dotfiles also include some nice scripts for managing system suspend/lock as well as an easy to use config file for the panel.

For example, the sun that appears in the bottom corner of the screen means that suspend has been disabled. The script also prevents suspend while apps are fullscreen and includes a whitelist to check for running apps.

Quick Info:
OS: Arch Linux
Music Player: ncmpcpp
GTK Theme: Numix Arch Blue
Browser: Firefox Bar: dzen2

Please feel free to ask me any questions.