Sunday, April 27, 2014

Custom i3-status bar and SLiM configuration

In this post, I'll show how to change theme and other configuration for SLiM login manager, how to setup conky to create customized i3-status bar and at the end I'll cleanup old unnecessary KDE packages, no longer needed in i3.


SLiM customization:
In Archlinux slim configuration file is /etc/slim.conf. This file needs few adjustments:
1. enable numlock
    numlock             on
2. disable sessiondir
    #sessiondir            /usr/share/xsessions/
3. change default user (in my case to krisko)
    default_user        krisko
4. set focus password
    focus_password      yes
5. change current theme
    current_theme       krisko
Now we will create our theme. Slim themes are in /usr/share/slim/themes/.
Copy the default theme and customize it:
cd /usr/share/slim/themes/
cp -ar default krisko
-now is a good time to replace background.jpg with your picture
and edit slim.theme to your needs. Example of my slim theme:
# Messages (ie: shutdown)
msg_color               #FFFFFF
msg_font                DejaVuSansMono:size=18:bold:dpi=75
msg_x                   50%
msg_y                   40%
msg_shadow_color #702342
msg_shadow_xoffset 1
msg_shadow_yoffset 1

# valid values: stretch, tile, center, color
background_style        tile
background_color        #eedddd

# Input controls
#input_panel_x           55%
#input_panel_y           75%
input_panel_x           520
input_panel_y           350
input_name_x            394
input_name_y            181
input_font              DejaVuSansMono:size=12:dpi=75
input_color             #000000

# Username / password request
username_font           DejaVuSansMono:size=14:bold:dpi=75
username_color          #f9f9f9
username_x              280
username_y              183
password_x              50%
password_y              183
username_shadow_color   #702342
username_shadow_xoffset 1
username_shadow_yoffset 1

username_msg            Username:
password_msg            Password:

Here's my Slim screenshot:

Custom i3-status bar
i3-status bar uses text string to display information. This can be easily used with conky, which can output string information.

First step is to prepare script to produce first part of JSON string (e.g. ~/bin/conky-i3bar):
#!/bin/sh

# Send the header so that i3bar knows we want to use JSON:
echo '{"version":1}'

# Begin the endless array.
echo '['

# We send an empty first array of blocks to make the loop simpler:
echo '[],'

# Now send blocks with information forever:
# use this if i3-status bar produces parsing error
#if [ ! -f /tmp/conky-i3bar ]; then
#   #sleep 16 
#   touch /tmp/conky-i3bar
#fi

exec conky -c $HOME/.conky/conky-i3bar

##################
# ChangeLog/TODO #
##################
# 1.0.0 2014-03-16 Added changelog/todo section
# 1.0.1 2014-04-13 Commented out obsolete section
##################

Next step is the conky configuration (~/.conky/conky-i3bar). I use Awesome font, on archlinux you can install it from AUR (package ttf-font-awesome).
out_to_x no
own_window no
out_to_console yes
background no
max_text_width 0

# Update interval in seconds
update_interval 5.0

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Shortens units to a single character (kiB->k, GiB->G, etc.). Default is off.
short_units yes

# How strict should if_up be when testing an interface for being up?
# The value is one of up, link or address, to check for the interface
# being solely up, being up and having link or being up, having link
# and an assigned IP address.
if_up_strictness address

# Add spaces to keep things from moving about?  This only affects certain objects.
# use_spacer should have an argument of left, right, or none
use_spacer left

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

#mdp password
mpd_password mpdPassword

#templates
template0 0
template1 1
template2 100
template3 Playing

# Stuff after 'TEXT' will be formatted on screen
TEXT
# send user activity when on youtube (IP 4 antik)
${if_match ${template0} < ${exec netstat -an | grep 88.212.9.[0-9][0-9].*:80 | grep -c ESTABLISHED}}${execi 180 xdotool key Control_L}${endif}
# send user activity when vlc is running
${if_running vlc}${execi 180 xdotool key Control_L}${endif}

# JSON for i3bar

 [{ "full_text" : "${if_gw} ${execi 1800 weather -a KE}${endif}" , "color" : "\#ffffff" },
 { "full_text" : "${if_mpd_playing}${if_match "${mpd_status}" == "${template3}"} ${else} ${endif}${mpd_elapsed}/${mpd_length} ${mpd_smart}${endif}" , "color" : ${if_match ${template1} == ${exec mpcctrl current}}"\#ff0000"${else}"\#b0e2ff"${endif} },
  { "full_text" : "${if_match ${template2} != ${exec acpi | awk '{print $4" "$5}' | sed -e 's/% $//'}}Bat: ${execi 60 acpi | awk '{print $4" "$5}' | sed -e 's/ $//'}${endif}" , "color" : "\#ffffff" },
  { "full_text" : "${if_match ${template0} != ${tcp_portmon 21 21 count}}FTP: ${tcp_portmon 21 21 rip 0} ${tcp_portmon 21 21 rhost 0}${endif}" , "color" : "\#ff0000" },
  { "full_text" : "${if_match ${template0} != ${tcp_portmon 22 22 count}}${execi 300 notify-send "SSH status" \ "New connection has been established!" -t 9000}SSH: ${tcp_portmon 22 22 rip 0} ${tcp_portmon 22 22 rhost 0}${endif}" , "color" : "\#ff0000" },
  { "full_text" : " ${if_up tun0}${addr tun0}${else}VPN${endif}" , "color" : ${if_up tun0} "\#00ff00"${else}"\#ff0000"${endif} },
  { "full_text" : "${if_up wlan0}${wireless_link_qual_perc wlan0}% @ ${wireless_essid wlan0} ${addr wlan0}${else} down${endif}" , "color" : ${if_up wlan0} "\#00ff00"${else}"\#ff0000"${endif} },
  { "full_text" : " ${if_up eth0}${addr eth0}  ${totaldown eth0}  ${totalup eth0}${else}down${endif}" , "color" : ${if_up eth0} "\#00ff00"${else}"\#ff0000"${endif} },
  { "full_text" : " C:${execi 60 acpi -t | cut -d " " -f 4 | cut -d "." -f 1}° G:${exec nvidia-smi | awk '{print $3}' | grep -A1 GeForce | tail -n 1 | sed -e 's/C$//'}°" , "color" : "\#ffffff" },
  { "full_text" : " ${memperc}%" , "color" : ${if_match ${memperc}<70}"\#ffffff"${else}"\#ff0000"${endif} },
  { "full_text" : " ${loadavg 1} ${cpu cpu0}%", "color" : ${if_match ${loadavg 1}<3}"\#ffffff"${else}"\#ff0000"${endif} },
  { "full_text" : " ${execi 5 setxkbmap -query | awk '{if (NR==3) print $2}'}" , "color" : "\#ffffff" },
  { "full_text" : " ${execi 5 date +"%a %d %b %H:%M"}", "color" : "\#ffffff" },
  { "full_text" : "${if_match ${mpd_vol}<25} ${else}${if_match ${mpd_vol}<50} ${else} ${endif}${endif} ${mpd_vol}%" , "color" : "\#00cdcd" }],
Now add to .i3/config:
bar {
    status_command $HOME/bin/conky-i3bar
    position top
}
And this is how it looks like:

NOTE: if you have problems with displaying new font in i3-status, uncomment font pango:DejaVu Sans Mono 10 in .i3/config

Cleaning old KDE packages:
As we have switched to i3 from KDE, there are many packages installed we don't need anymore.
Here is a list of them:
-first install some kind of terminal, e.g.:
    xfce4-terminal

-then remove old packages (pacman -R) (separated into groups):

ccrtp jsoncpp kdeedu-marble kdenetwork-kopete kdeplasma-addons-applets-bball kdeplasma-addons-applets-binary-clock kdeplasma-addons-applets-blackboard kdeplasma-addons-applets-bookmarks kdeplasma-addons-applets-bubblemon kdeplasma-addons-applets-calculator kdeplasma-addons-applets-charselect kdeplasma-addons-applets-comic kdeplasma-addons-applets-community kdeplasma-addons-applets-dict kdeplasma-addons-applets-eyes kdeplasma-addons-applets-fifteenpuzzle kdeplasma-addons-applets-filewatcher kdeplasma-addons-applets-frame kdeplasma-addons-applets-fuzzy-clock kdeplasma-addons-applets-icontasks kdeplasma-addons-applets-incomingmsg kdeplasma-addons-applets-kimpanel kdeplasma-addons-applets-knowledgebase kdeplasma-addons-applets-kolourpicker kdeplasma-addons-applets-konqprofiles kdeplasma-addons-applets-konsoleprofiles kdeplasma-addons-applets-lancelot kdeplasma-addons-applets-leavenote kdeplasma-addons-applets-life kdeplasma-addons-applets-luna kdeplasma-addons-applets-magnifique kdeplasma-addons-applets-mediaplayer kdeplasma-addons-applets-microblog kdeplasma-addons-applets-news kdeplasma-addons-applets-notes kdeplasma-addons-applets-nowplaying kdeplasma-addons-applets-paste kdeplasma-addons-applets-pastebin kdeplasma-addons-applets-plasmaboard kdeplasma-addons-applets-previewer kdeplasma-addons-applets-qalculate kdeplasma-addons-applets-rememberthemilk kdeplasma-addons-applets-rssnow kdeplasma-addons-applets-showdashboard kdeplasma-addons-applets-showdesktop kdeplasma-addons-applets-social-news kdeplasma-addons-applets-spellcheck kdeplasma-addons-applets-systemloadviewer kdeplasma-addons-applets-timer kdeplasma-addons-applets-unitconverter kdeplasma-addons-applets-weather kdeplasma-addons-applets-weatherstation kdeplasma-addons-applets-webslice kdeplasma-addons-containments kdeplasma-addons-libs kdeplasma-addons-runners-audioplayercontrol kdeplasma-addons-runners-browserhistory kdeplasma-addons-runners-characters kdeplasma-addons-runners-contacts kdeplasma-addons-runners-converter kdeplasma-addons-runners-datetime kdeplasma-addons-runners-dictionary kdeplasma-addons-runners-events kdeplasma-addons-runners-katesessions kdeplasma-addons-runners-konquerorsessions kdeplasma-addons-runners-konsolesessions kdeplasma-addons-runners-kopete kdeplasma-addons-runners-mediawiki kdeplasma-addons-runners-spellchecker kdeplasma-addons-runners-translator kdeplasma-addons-runners-youtube kdeplasma-addons-wallpapers-mandelbrot kdeplasma-addons-wallpapers-marble kdeplasma-addons-wallpapers-pattern kdeplasma-addons-wallpapers-potd kdeplasma-addons-wallpapers-qmlwallpapers kdeplasma-addons-wallpapers-virus kdeplasma-addons-wallpapers-weather kdesdk-kate libgadu libmsn libsrtp libzrtpcpp mediastreamer ortp qca-ossl qoauth ucommon kde-meta-kdeplasma-addons 

kdeartwork-colorschemes kdeartwork-desktopthemes kdeartwork-emoticons kdeartwork-iconthemes kdeartwork-kscreensaver  kdeartwork-wallpapers kdeartwork-weatherwallpapers kde-meta-kdeartwork 

kde-meta-kdemultimedia 

libdiscid libmusicbrainz3 kdemultimedia-dragonplayer kdemultimedia-juk kdemultimedia-kscd 

kde-meta-kdebase 

kdebase-dolphin kdebase-keditbookmarks kdebase-konqueror nepomuk-widgets tidyhtml kde-wallpapers kdebase-kdepasswd kdebase-kfind kdebase-konq-plugins kdebase-plasma 

kde-meta-kdeadmin 

libftdi-compat libirman libkcddb libkcompactdisc  libmusicbrainz5 libxvmc libxxf86dga lirc-utils mpg123 mplayer xf86dgaproto xorg-iceauth  kdeadmin-kcron kdeadmin-kuser  kdemultimedia-audiocd-kio kdemultimedia-ffmpegthumbs kdemultimedia-mplayerthumbs kdeplasma-applets-networkmanagement kdeutils-print-manager sessionk-git

-make sure some important package wasn't removed (pacman -S):

akonadi cln iso-codes kde-base-artwork kdebase-workspace kdepim-runtime kdepimlibs libdmtx libical libkfbapi libkgapi libkolab libkolabxml libqalculate libusb-compat libxaw libxklavier libxres lm_sensors mcpp polkit-kde prison qrencode xerces-c xorg-xmessage xorg-xprop xorg-xrandr xorg-xrdb xorg-xsetroot kdeartwork-styles

No comments:

Post a Comment