Desktop/i3

From LunaSys
Revision as of 10:21, 25 February 2013 by Eadam (talk | contribs) (→‎Troubleshooting)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

i3

For more information, see the official doc

General Configuration

Font:

...
font pango:DejaVu Sans Mono 8
...

Screenshot:

...
bindsym $mod+x --release exec --no-startup-id import /tmp/latest-screenshot.png
...

i3status

Example .i3status.conf

general {
	output_format = "i3bar"
	colors = true
	interval = 5
}

order += "disk /"
order += "ethernet eth0"
order += "load"
order += "time"

ethernet eth0 {
	# if you use %speed, i3status requires the cap_net_admin capability
	format_up = "E: %ip (%speed)"
	format_down = "E: down"
}
time {
	format = "%Y-%m-%d %H:%M"
}
load {
	format = "%5min"
}


Custom i3status command, the python way

Code from here

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# This script is a simple wrapper which prefixes each i3status line with custom
# information. It is a python reimplementation of:
# http://code.stapelberg.de/git/i3status/tree/contrib/wrapper.pl
#
# To use it, ensure your ~/.i3status.conf contains this line:
#     output_format = "i3bar"
# in the 'general' section.
# Then, in your ~/.i3/config, use:
#     status_command i3status | ~/i3status/contrib/wrapper.py
# In the 'bar' section.
#
# In its current version it will display the cpu frequency governor, but you
# are free to change it to display whatever you like, see the comment in the
# source code below.
#
# © 2012 Valentin Haenel <valentin.haenel@gmx.de>
#
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law. You can redistribute it and/or modify it under
# the terms of the Do What The Fuck You Want To Public License (WTFPL), Version
# 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more
# details.

import sys
import json

def get_load():
    """ Get the current governor for cpu0, assuming all CPUs use the same. """
    return '새해복많이받으새요'

def get_governor():
    """ Get the current governor for cpu0, assuming all CPUs use the same. """
    with open('/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor') as fp:
        return fp.readlines()[0].strip()

def print_line(message):
    """ Non-buffered printing to stdout. """
    sys.stdout.write(message + '\n')
    sys.stdout.flush()

def read_line():
    """ Interrupted respecting reader for stdin. """
    # try reading a line, removing any extra whitespace
    try:
        line = sys.stdin.readline().strip()
        # i3status sends EOF, or an empty line
        if not line:
            sys.exit(3)
        return line
    # exit on ctrl-c
    except KeyboardInterrupt:
        sys.exit()

if __name__ == '__main__':
    # Skip the first line which contains the version header.
    print_line(read_line())

    # The second line contains the start of the infinite array.
    print_line(read_line())

    while True:
        line, prefix = read_line(), ''
        # ignore comma at start of lines
        if line.startswith(','):
            line, prefix = line[1:], ','

        j = json.loads(line)
        # insert information into the start of the json, but could be anywhere
        # CHANGE THIS LINE TO INSERT SOMETHING ELSE
        j.insert(0, {'full_text' : '%s' % get_load(), 'name' : 'gov'})
        # and echo back new encoded json
        print_line(prefix+json.dumps(j))

.i3/config

...
bar {
	status_command i3status --config ~/.i3status.conf | ~/i3wrapper.py
}
...

Custom i3status command

/usr/bin/i3custombar

i3status | while :
do
   read line
   echo "새해복많이받으새요 $line" || exit 1
done

.i3/config

...
bar {
	status_command /usr/bin/i3custombar
	font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
	font pango:DejaVu Sans Mono 10
}
...

Troubleshooting

  • Xorg is very slow, possible cause: ubuntu overlay scrollbars. To deactivate them (source):
apt-get remove overlay-scrollbar
echo "export LIBOVERLAY_SCROLLBAR=0" > /etc/X11/Xsession.d/80overlayscrollbars