From a11ea3b0f8c65799e0adba34a6eaaef22267446b Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Sun, 3 Apr 2016 14:34:04 +0200
Subject: Using xmobar instead of i3bar/i3status
---
 bin/i3ws                     | 35 +++++++++++++++++++++++++++++++++++
 bin/nowplaying               |  2 ++
 i3.symlink/config            | 18 ++++++++----------
 system/i3status.conf.symlink |  2 +-
 system/xmobarrc.symlink      | 22 +++++++++++++---------
 5 files changed, 59 insertions(+), 20 deletions(-)
 create mode 100755 bin/i3ws
 create mode 100755 bin/nowplaying
diff --git a/bin/i3ws b/bin/i3ws
new file mode 100755
index 0000000..a1c487a
--- /dev/null
+++ b/bin/i3ws
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+from functools import partial
+import json
+from subprocess import check_output
+import sys
+
+def get_unique(func, wss):
+    return list(set(map(func, wss)))
+
+def get_unique_key(key, wss):
+    return get_unique(lambda ws: ws[key], wss)
+
+def show_workspace(ws):
+    color = 'f00' if ws['urgent'] else \
+            '00fcff' if ws['focused'] else \
+            '6aa3f8' if ws['visible'] else \
+            '777'
+    return '%s' % (color, ws['name'])
+
+def show_output(wss, op):
+    wss = list(filter(lambda ws: ws['output'] == op, wss))
+    wss.sort(key=lambda ws: ws['name'])
+
+    return op + ' ' + ' '.join(map(show_workspace, wss))
+
+def main():
+    i3ws = check_output(['i3-msg', '-t', 'get_workspaces']).decode('utf-8')
+    wss = json.loads(i3ws)
+    
+    outputs = sorted(get_unique_key('output', wss))
+    print(' * '.join(map(partial(show_output, wss), outputs)))
+
+if __name__ == '__main__':
+    main()
+
diff --git a/bin/nowplaying b/bin/nowplaying
new file mode 100755
index 0000000..650e6e8
--- /dev/null
+++ b/bin/nowplaying
@@ -0,0 +1,2 @@
+#!/bin/sh
+cmus-remote -Q | grep '^tag \(artist\|album\|title\) ' | cut -d' ' -f 3- | tr '\n' '\t' | awk 'BEGIN { FS = "\t" } ; { print $3 " (" $2 ", " $1 ")" }'; echo -n ' '
diff --git a/i3.symlink/config b/i3.symlink/config
index 988c4e7..c658e43 100644
--- a/i3.symlink/config
+++ b/i3.symlink/config
@@ -4,8 +4,8 @@ floating_modifier $mod
 font pango:DejaVu Sans Mono 8
 focus_follows_mouse no
 
-# kill focused window
-bindsym $mod+Shift+Q kill
+# Bar
+exec xmobar -d
 
 # Autolock
 exec xautolock -time 3 -locker 'i3lock -d'
@@ -15,6 +15,9 @@ bindsym $mod+Control+Shift+l exec xautolock -locknow
 bindsym $mod+d exec dmenu_run
 bindsym $mod+p exec passmenu -i
 
+# kill focused window
+bindsym $mod+Shift+Q kill
+
 # Programs
 bindsym $mod+Return exec uxterm
 bindsym $mod+Shift+v exec uxterm -e vim
@@ -26,9 +29,9 @@ bindsym Shift+Print exec scrot -u '/tmp/%Y-%m-%d-%H%M%S_$wx$h.png'
 bindsym --release Control+Print exec scrot -s '/tmp/%Y-%m-%d-%H%M%S_$wx$h.png'
 bindsym XF86KbdBrightnessUp exec sudo -A ~/bin/kbdbacklight up
 bindsym XF86KbdBrightnessDown exec sudo -A ~/bin/kbdbacklight down
-bindsym XF86AudioMute exec amixer sset Master toggle && kill -n 10 `pidof i3status`
-bindsym XF86AudioRaiseVolume exec amixer sset Master 1%+ && kill -n 10 `pidof i3status`
-bindsym XF86AudioLowerVolume exec amixer sset Master 1%- && kill -n 10 `pidof i3status`
+bindsym XF86AudioMute exec amixer sset Master toggle
+bindsym XF86AudioRaiseVolume exec amixer sset Master 1%+
+bindsym XF86AudioLowerVolume exec amixer sset Master 1%-
 bindsym $mod+F6 exec xbacklight -inc 5 -time 80
 bindsym $mod+F5 exec xbacklight -dec 5 -time 80
 
@@ -110,8 +113,3 @@ mode "resize" {
     bindsym $mod+r mode "default"
 }
 
-bar {
-    font pango:DejaVu Sans Mono, 9
-    status_command i3status
-}
-
diff --git a/system/i3status.conf.symlink b/system/i3status.conf.symlink
index c011019..211b6e8 100644
--- a/system/i3status.conf.symlink
+++ b/system/i3status.conf.symlink
@@ -28,7 +28,7 @@ wireless wlan0 {
 }
 
 battery 0 {
-    format = "%status %percentage %remaining %emptytime"
+    format = "%status %percentage %remaining"
     status_chr = "⚇"
     status_bat = "⚡"
     status_full = "☻"
diff --git a/system/xmobarrc.symlink b/system/xmobarrc.symlink
index cc55142..feef098 100644
--- a/system/xmobarrc.symlink
+++ b/system/xmobarrc.symlink
@@ -1,27 +1,31 @@
-Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
+Config
+  { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
   , borderColor = "black"
   , border = TopB
   , bgColor = "black"
   , fgColor = "grey"
-  , position = BottomW L 100
+  , position = Bottom
   , commands = 
-    [ Run Weather "EHDL" ["-t","C","-L","18","-H","25","--low","lightblue","--normal","green","--high","red"] 9000
-    , Run DynNetwork ["-L","10000","-H","50000","--low","green","--normal","orange","--high","red"] 10
-    , Run Com "wireless-status" ["wlan0"] "wlan0stat" 10
+    [ Run Com "i3ws" [] "i3ws" 10
     , Run Battery ["--normal","red","--high","green","-t","% ()"] 150
+    , Run Volume "default" "Master" [] 10
     , Run Cpu ["-L","10","-H","50","--low","green","--normal","orange","--high","red"] 10
     , Run Memory ["-t","Mem: %","-L","30","-H","60","--low","green","--normal","orange","--high","red"] 10
     , Run Swap ["-L","10","-H","30","--low","green","--normal","orange","--high","red"] 10
-    , Run Com "uname" ["-s","-r"] "" 36000
+    , Run DynNetwork ["-L","10000","-H","50000","--low","green","--normal","orange","--high","red"] 10
+    , Run Com "wireless-status" ["wlan0"] "wlan0stat" 10
+    
+    , Run Com "nowplaying" [] "nowplaying" 50
+    , Run Date "%a %b %_d %Y %H:%M:%S" "date" 50
+    , Run Com "uname" ["-s","-r"] "" 0
     , Run Kbd [("us(intl)", "US")
               ,("us(dvorak-intl)", "DV")
               ,("ru(phonetic)", "RU")
               ,("il(biblicalSIL)", "HE")]
-    , Run Date "%a %b %_d %Y %H:%M:%S" "date" 10
-    , Run StdinReader
+    , Run Weather "EHDL" ["-t"," °C","-L","15","-H","25","--low","lightblue","--normal","green","--high","red"] 9000
     ]
   , sepChar = "%"
   , alignSep = "}{"
-  , template = "%StdinReader% | %battery% | %cpu% | %memory% * %swap% | %dynnetwork% %wlan0stat% }{%date% | %uname% | %kbd% | %EHDL% "
+  , template = "%i3ws% | %battery% | %default:Master% | %cpu% | %memory% * %swap% | %dynnetwork% %wlan0stat% }{ %nowplaying% | %date% | %uname% | %kbd% | %EHDL% "
   }
 -- vim:ft=haskell:tw=9999:
-- 
cgit v1.2.3