module Monitors where import Xmobar import Config import Control.Concurrent import Control.Concurrent.Async (async) import Control.Concurrent.STM import qualified Data.Char as Char import qualified Text.Printf as Printf topProc p = TopProc (p <~> ["-t" , " \ \ยท " , "-w", "10", "-L" , "10", "-H", "80"]) 15 topProc' p = TopProc (p <~> ["-t" , " \ \ยท " , "-w", "10", "-L" , "10", "-H", "80"]) 15 wireless p n = Wireless n (p >~< ["-t", "" -- fc (pLow p) (fni "\xf1eb " ++ "") -- \xf09e , "-W", "5", "-M", "15" , "-m", "3" , "-L", "20", "-H", "80"]) 20 wirelessx p n = Wireless n (p >~< ["-t", "" ++ fn 1 "โ†‘ " ++ " " ++ fn 1 "โ†“" ++ " " -- fc (pLow p) (fni "\xf1eb " ++ "") -- \xf09e , "-W", "5", "-M", "15" , "-m", "3" , "-L", "20", "-H", "80"]) 20 cpu p = MultiCpu (p <~> ["-t", "" , "-S", "on", "-c", " " , "-L", "30", "-H", "70" , "-p", "3", "-a", "l"]) 10 multiCPU p = MultiCpu (p <~> ["-t", "" , "-S", "on", "-b", " ", "-f", "*" , "-c", " " , "-L", "30", "-H", "70" , "-p", "3", "-a", "l"]) 10 cpuBars p = MultiCpu (mkArgs p ["--template" , " %" , "-L", "50", "-H", "85", "-w", "3"] ["--fallback-icon-pattern", "" , "--contiguous-icons"]) 10 cpuFreq p = CpuFreq (p <~> ["-t" , " " , "-L", "1", "-H", "2", "-S", "Off" , "-d", "2"]) 50 uptime p = Uptime (p <~> [ "-t" , " ", "-m", "3", "-c", "0", "-S" , "On" , "-L", "10", "-H", "100"]) 600 weather' tmp st p = WeatherX st [ ("", "\129695") , ("clear", "๐Ÿ”†") , ("sunny", "๐Ÿ”†") , ("fair", "๐Ÿ”†") , ("mostly clear", "๐ŸŒค๏ธ") , ("mostly sunny", "๐ŸŒค๏ธ") , ("partly sunny", "โ›…") , ("obscured", "๐ŸŒ") , ("fog", "๐ŸŒซ๏ธ") , ("foggy", "๐ŸŒซ๏ธ") , ("cloudy", "โ˜๏ธ") , ("overcast", "โ˜๏ธ") , ("partly cloudy", "โ›…") , ("mostly cloudy", "โ˜๏ธ") , ("considerable cloudiness", "๐ŸŒ‚") , ("light rain", "๐ŸŒฆ๏ธ") , ("rain", "๐ŸŒจ๏ธ") , ("ice crystals", "โ„๏ธ") , ("light snow", "๐ŸŒจ๏ธ") , ("snow", "โ„๏ธ") ] (mkArgs p ["-t", tmp , "-L", "10", "-H", "25" , "-T", "20"] ["-w", ""]) 18000 weather = weather' " ยฐ " -- "https://wttr.in?format=" ++ fnn 3 "%c" ++ "+%t+%C+%w++" ++ fnn 1 "%m" -- , Run (ComX "curl" [wttrURL "Edinburgh"] "" "wttr" 18000) wttrURL l = "https://wttr.in/" ++ l ++ "?format=" ++ fmt where fmt = fnn 2 "+%c+" ++ "+%t+%C+" ++ fn 5 "%w" fnn n x = urlEncode ("") ++ x ++ urlEncode "" encode c | c == ' ' = "+" | Char.isAlphaNum c || c `elem` "-._~" = [c] | otherwise = Printf.printf "%%%02X" c urlEncode = concatMap encode batt p = BatteryN ["BAT0"] ["-t", " " , "-S", "Off", "-d", "0", "-m", "2" , "-L", "10", "-H", "90", "-p", "2" , "--low", pHigh p, "--normal", pNormal p, "--high", pLow p , "--" , "-P" , "-a", "notify-send -u critical 'Battery running out!!!!!!'" , "-A", "7" , "-i", fn 1 "\9211" , "-O", fn 1 " \9211" ++ " " , "-o", fn 1 " ๐Ÿ”‹" ++ " " , "-H", "10", "-L", "7" , "-h", pHigh p, "-l", pLow p] 50 "batt0" iconBatt p = BatteryN ["BAT0"] ["-t", "" , "-S", "Off", "-d", "0", "-m", "2" , "-L", "10", "-H", "90", "-p", "2" , "-W", "0", "-f", "\xf244\xf243\xf243\xf242\xf242\xf242\xf241\xf241\xf241\xf240" , "--low", pHigh p, "--normal", pNormal p, "--high", pLow p , "--" , "-P" , "-a", "notify-send -u critical 'Battery running out!!!!!!'" , "-A", "5" , "-i", fn 1 "\xf011" , "-O", fn 1 "\xf1e6 " ++ " " , "-o", fn 1 "" ++ " " , "-H", "10", "-L", "7" , "-h", pHigh p, "-l", pLow p] 50 "batt0" rizenTemp p = K10Temp "0000:00:18.3" (mkArgs p ["-t", "ยฐC", "-L", "40", "-H", "70", "-d", "0"] []) 50 thinkTemp p = MultiCoreTemp (mkArgs p ["-t", "ยฐC", "-L", "40", "-H", "70", "-d", "0"] []) 50 avgCoretemp p = MultiCoreTemp (p <~> ["-t", "ยฐ" , "-L", "50", "-H", "75", "-d", "0"]) 50 coreTemp p = MultiCoreTemp (p <~> ["-t", "ยฐ ยฐ" , "-L", "50", "-H", "75", "-d", "0"]) 50 load p = Load (p <~> ["-t" , " ", "-L", "1", "-H", "3", "-d", "2"]) 300 diskU p = DiskU [("/", "") , ("/media/sda", " s ")] (p <~> ["-L", "20", "-H", "70", "-m", "1", "-p", "3"]) 20 diskArgs p = mkArgs p ["-f", "โ–‘", "-b", " ", "-L", "10000000", "-H" , "100000000" , "-W", "5", "-w", "5", "-p", "3"] ["--total-icon-pattern", "", "-c"] diskIO p = DiskIO [("rivendell-vg/root", " ")] (diskArgs p) 10 mail p = MailX [ ("I", "jao/inbox", pHigh p) , ("b", "bigml/bugs", pHigh p) , ("B", "bigml/inbox", "") , ("S", "bigml/support", "") , ("H", "jao/hacking", "") , ("D", "jao/drivel", "") , ("D", "bigml/drivel", pDim p) , ("R", "feeds/rss", pDim p) , ("E", "feeds/emacs", pDim p) , ("P", "feeds/prog", pDim p) , ("B", "jao/bills", pDim p) , ("L", "bigml/lists", pDim p) ] [ "-d", "~/var/mail", "-s", " "] "mail" nmmail = NotmuchMail "mail" [MailItem "J" "" qj, MailItem "B" "" qb] 100 where qb = "(tag:bigml or tag:alba) and tag:new" qj = "(tag:jao or tag:hacking or tag:bills) and tag:new" masterVol p = Volume "default" "Master" ["-t", " " , "--", "-C", pForeground p, "-c", "#8b4726" , "-O", fn 1 "\xf025" , "-o", fn 1 "\xf131" ] 10 captureVol = Volume "default" "Capture" ["-t", ""] 10 masterAlsa p = Alsa "default" "Master" ["-t", " " , "--", "-C", pForeground p, "-c", "#8b4726" , "-O", fn 1 "\xf025" , "-o", fn 1 "\xf131" ] captureAlsa = Alsa "default" "Capture" ["-t", ""] kbd p = Kbd [("us", ""), ("us(intl)", kbi pHigh)] -- kbi pDim where kbi a = fc (a p) (fn 1 " \xf11c") brightness = Brightness ["--", "-D", "intel_backlight"] 10 brightness' = Brightness ["--", "-D", "amdgpu_bl0", "-C", "brightness"] 10 memory = Memory [ "-t" ,":" , "-p", "2", "-W", "4","-d", "1" , "--", "--scale", "1024"] 20 dynNetwork p = DynNetwork (p <~> ["-t", fn 1 "โ†‘ " ++ " " ++ fn 1 "โ†“" ++ " " , "-L", "20", "-H", "1024000" , "-m", "5", "-W", "10", "-S", "Off"]) 10 netdev name icon = Network name ["-t", "", "-x", "", "--", "--up", icon] 20 vpnMark n = netdev n $ fn 2 "๐Ÿ”’ " -- fni "\xf0e8 " proton0 = vpnMark "proton0" tun0 = vpnMark "tun0" laTime = DateZone "%H" "" "America/Los_Angeles" "laTime" 10 localTime = Date "%a %d %R" "datetime" 10 trayPadding = Com "padding-width.sh" [] "tray" 20