provide ability to show unicode "level" notification

Bug #705032 reported by James Hunt
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
byobu
Triaged
Wishlist
Unassigned

Bug Description

Currently, byoby provides a large number of canned status notifiers. It would be useful if we also provided a means to script notifiers that display certain types of notifier using unicode characters.

For example, any notifier that has the concept of a "level" (volume, disk percentage, wifi quality, load average, memory, swap, etc) could be enhanced to allow some nice graphical sugar by utilizing unicode characters.

Attached is a script I've written (ulevel.sh) that has the following usage:

Usage: ulevel.sh [options]

Options:

 -c <num> : Current value of your indicator.
 -h : Show this help.
 -l : List available themes. If '-t' also specified,
              show all values for specified theme.
 -m <num> : Minimum value (default=0).
 -n : Supress output of newline character.
 -t <theme> : Name of theme.
 -x <num> : Maximum value (default=100).

Examples:

  # display character representing 27% from 'vbars_8' theme.
  ulevel.sh -c 27 -t vbars_8

  # display all glyphs in 'soli_numbers_a_10' theme
  ulevel.sh -l -t solid_numbers_a_10

Notes:

  - The final '_<number>' in a theme name denotes how many glyphs are
    available in this theme.

Thus, notifiers like /usr/lib/byobu/wifi_quality could be tweaked to call...

 ulevel.sh -c $quality -t vbars_8

... to provide a nice vertical bar whose height represents the % signal strength ($quality).

Tags: unicode

Related branches

Revision history for this message
James Hunt (jamesodhunt) wrote :
Revision history for this message
James Hunt (jamesodhunt) wrote :

Removed an rogue theme and added dice_6. We now have:

./ulevel.sh -l|while read theme; do ./ulevel.sh -l -t $theme; done
Listing theme 'shades_4'

░ ▒ ▓ █

Listing theme 'fractions_4'

¼ ½ ¾ ¹

Listing theme 'binary_thin_4'

⠀ ⢀ ⢠ ⢰

Listing theme 'binary_thick_4'

⠀ ⣀ ⣤ ⣶ ⣿

Listing theme 'quadrants_4'

◔ ◑ ◕ ●

Listing theme 'circles_5'

◦ ○ ◎ ◉ ●

Listing theme 'dice_6'

⚀ ⚁ ⚂ ⚃ ⚄ ⚅

Listing theme 'vbars_8'

▁ ▂ ▃ ▄ ▅ ▆ ▇ █

Listing theme 'hbars_8'

▏ ▎ ▍ ▌ ▋ ▊ ▉ █

Listing theme 'solid_numbers_a_10'

➊ ➋ ➌ ➍ ➎ ➏ ➐ ➑ ➒ ➓

Listing theme 'solid_numbers_b_10'

❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿

Listing theme 'circle_number_10'

➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Love it ;-)

Okay, so which of usr/lib/byobu/* could or should use these?

I've added some preliminary UTF8 support in a few scripts.

If you grab the source and grep, you'll see a few examples:
 bzr branch lp:byobu
 grep UTF8 byobu/usr/lib/byobu/*

Dustin

Changed in byobu:
importance: Undecided → Wishlist
status: New → Incomplete
Revision history for this message
James Hunt (jamesodhunt) wrote :

Hi Dustin,

I've updated this script slightly (see attached) to add a "-q" (quiet) option.

I think we could have ulevel / unicode versions of the following:

battery
cpu_temp (we'd need to consider /proc/acpi/thermal_zone/*/trip_points)
disk (% full atleast)
load_average - tricky one, would be nice to do this, but what is a reasonable maximum? servers can go pretty high :)
mem_used
wifi_quality (% strength atleast)

New ideas:

volume level (for left/right/other channels even).

I think if possible that we would provide unicode versions of the standard notifications, but also encourage users to make use of ulevel as a utility for building their own notifications.

Revision history for this message
James Hunt (jamesodhunt) wrote :

Related to ulevel, I have something else up my sleeve: ugraph.sh.

This lets you display a rolling graph of the levels of some notification. For example:

    |▃▆▆█▃|

I've put some test notifications that call ulevel and ugraph here:

  http://people.canonical.com/~jhunt/byobu/5_test_ugraph
  http://people.canonical.com/~jhunt/byobu/5_test_ulevel

Usage: ugraph.sh [options] [command [args...]]

Options:

 -f <file> : File to read data points from.
               (only required if no command specified).
 -h : Show this help.
 -m <num> : Minimum value (default=0).
 -n : Supress output of newline character.
 -p <points> : Specify number of data points in graph
               (default=5).
 -x <num> : Maximum value (default=100).

Examples:

  Using ugraph.sh to run a command, rotate log and display graph.

  Here we specify a command to display available memory.
  Trailing echo adds a required newline
  Note no filename specified.

    ugraph.sh "(/usr/lib/byobu/mem_used |sed 's/% //g';echo)"

  Using ugraph.sh just to rotate log and display the graph

    file=/tmp/data.dat
    some_command >>
    ugraph.sh -f

Notes:

  - If you specify 'command', care must be taken with shell quoting to
    avoid expansion prior to this script running the command.

Revision history for this message
James Hunt (jamesodhunt) wrote :

Forgot to say, if anyone can find any other interesting sequences we could add to ulevel, let us all know:

  http://en.wikipedia.org/wiki/List_of_Unicode_characters

Revision history for this message
James Hunt (jamesodhunt) wrote :
Revision history for this message
James Hunt (jamesodhunt) wrote :
Revision history for this message
James Hunt (jamesodhunt) wrote :

Oops! Noticed a bug-ette in the ugraph usage. Updated script attached (and on people.canonical.com)

Revision history for this message
James Hunt (jamesodhunt) wrote :

Added:

(1) "ratings themes" so you can do this:

$ ulevel.sh -c 73 -t stars_2
★★★☆☆

(2) New "-u" option to specify a user (rating) theme:

$ ulevel.sh -c 58 -u ". ❤"
❤❤...

Revision history for this message
James Hunt (jamesodhunt) wrote :

ugraph changes:

- simplified logic
- increased speed
- made file rotation atomic
- New "-r" option to *not* rotate the specified file

Revision history for this message
James Hunt (jamesodhunt) wrote :
Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Hmm, okay, so for Natty, we're past Feature Freeze.

Your base version of these tools are in the latest byobu release, and in the Natty archive. I can pull your latest changes, assuming they're really only bug fixes.

Note that I have renamed all of your helper scripts to /usr/bin/byobu-*. Can you take a look at merging your changes into the latest branch of lp:byobu?

I think what I would like to do for this cycle is to ship the helper scripts, such that people can make custom scripts in their ~/.byobu/bin/* dir for the near term, and we can get a feel of what the possibilities are.

Cool?

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Marking this bug triaged again.

We'll support this through tmux in the near term. And if we ever get a GNU Screen release that supports UTF8 in the hardstatus, we'll revisit the Screen parts of this in Byobu. (Note that there are patches for this in Screen's git repo, but it's unreleased and the particular cherry-picked patches are buggy).

Changed in byobu:
status: Incomplete → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.