sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

index.md (2081B)


      1 AnsiStatusColors
      2 ================
      3 Colorize your status bar using ansi escape sequences.
      4 
      5 Description
      6 -----------
      7 Lets you put colored text in your status bar, but you don't have define them in
      8 your config.h. Instead, just put the ansi escape sequence in the output of your
      9 status bar script to print in color, as you would in a terminal.
     10 
     11 Usage
     12 -----
     13 Just like you'd use them for colorizing a shell script.
     14 
     15 More info is here:
     16 [http://www.frexx.de/xterm-256-notes/](http://www.frexx.de/xterm-256-notes/)
     17 
     18 An ansi escape sequence is in the form:
     19 
     20 	\e[<code>m
     21 
     22 where:
     23 
     24 	\e - escape - ascii 27 / hex 1b / octal 033
     25 	[ - literal bracket
     26 	m - literal 'm'
     27 
     28 The code is one of the following:
     29 
     30 	0 
     31 	    - reset colors to default
     32 
     33 	n;m
     34 
     35 	    n -
     36 	        o - normal color
     37 	        1 - 'bright' color
     38 
     39 	    m -
     40 	        30-37 - foreground
     41 	        40-47 - background
     42 
     43 	n;5;m
     44 	    
     45 	    n - 
     46 	        38 - foreground
     47 	        48 - background
     48 	    5 - 
     49 	        literal '5'
     50 	    m - 
     51 	        0-15 - classic ansi color
     52 	        16-231 - xterm 256-color rgb color
     53 	        232-255 - grayscale
     54 
     55 In vim, to create a literal 'escape' character, type ctrl-v, esc.
     56 in perl/python/c, within a string literal, it's "\x1b".
     57 
     58 Example
     59 -------
     60 	#!/usr/bin/env python
     61 	##testcoloredstatus.py
     62 
     63 	from subprocess import call,check_output
     64 
     65 	redfg = '\x1b[38;5;196m' #hex
     66 	redbg = '\033[48;5;196m'  #octal
     67 	blackbg = '\x1b[48;5;16m'
     68 	reset = '\x1b[0m'
     69 
     70 	call(['xsetroot','-name',''.join(
     71 	    [
     72 	        redfg,
     73 	        'hello ',
     74 	        reset,
     75 	        redbg,
     76 	        'world',
     77 	        reset,
     78 	        '! bar graph: 50% ',
     79 	        redbg,
     80 	        ' '*5,
     81 	        blackbg,
     82 	        ' '*5,
     83 	        reset,
     84 	        '  ',
     85 	        check_output("date").strip()
     86 	    ]
     87 	)], shell=False)
     88 
     89 Screenshot
     90 ----------
     91 My battery is discharging and my wifi signal is iffy...
     92 
     93 ![alt text](ansistatuscolors.png)
     94 
     95 Download
     96 --------
     97 * [dwm-ansistatuscolors-5.9.diff][dwm-ansistatuscolors-5.9.diff]
     98 * [dwm-ansistatuscolors-6.0.diff][dwm-ansistatuscolors-6.0.diff]
     99 
    100 Author
    101 ------
    102 * Brandon Dowell <brandon DOT dowell AT gmail>