Created
September 27, 2014 09:55
-
-
Save funrep/179999d4917621ec26e3 to your computer and use it in GitHub Desktop.
My dwm statusbar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# statusbar | |
while true; do | |
xsetroot -name "$( statusbar )" | |
sleep 1m # Update time every minute | |
done & | |
# settings | |
xset -b | |
xrdb -merge ~/.XResources | |
xsetroot -solid "#002b36" | |
xsetroot -cursor_name left_ptr & | |
# startup programs | |
exec dwm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
import System.Process | |
import System.Exit | |
run x y z = do | |
(err, s, _) <- readProcessWithExitCode x y z | |
case err of | |
ExitSuccess -> return s | |
_ -> return "" | |
main = do | |
battery <- run "/usr/bin/acpi" ["-b"] "" | |
temp <- run "/usr/bin/acpi" ["-t"] "" | |
date <- run "/bin/date" ["+\"%F %R\""] "" | |
-- volume <- run "/usr/bin/amixer" [] "" | |
network <- run "/usr/bin/wicd-cli" ["-y", "-d"] "" | |
let s = unwords [networkParse network, tempParse temp, batteryParse battery, | |
dateParse date] | |
putStrLn s | |
batteryParse :: String -> String | |
batteryParse s = let | |
s' = words s | |
in case find (== "Discharging,") s' of | |
Just s'' -> take 3 . head . tail $ dropWhile (/= s'') s' | |
Nothing -> "100%" | |
tempParse :: String -> String | |
tempParse s = let | |
s' = words s | |
in case find (== "ok,") s' of | |
Just s'' -> let | |
cpu1 = take 2 . head . tail $ dropWhile (/= s'') s' | |
cpu2 = take 2 . head . tail . dropWhile (/= s'') . tail $ dropWhile (/= s'') s' | |
in cpu1 ++ "°" ++ " " ++ cpu2 ++ "°" | |
Nothing -> "XX° YY°" | |
networkParse :: String -> String | |
networkParse s = let | |
s' = words s | |
in case find (== "Rates:") s' of | |
Just s'' -> let | |
s''' = take 2 . tail $ dropWhile (/= s'') s' | |
in unwords s''' | |
Nothing -> "5 Tb/s" | |
dateParse :: String -> String | |
dateParse = init . init . tail |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment