diff options
| -rw-r--r-- | lib/Attic.hs | 51 | ||||
| -rw-r--r-- | lib/Config.hs | 9 | ||||
| -rw-r--r-- | lib/Monitors.hs | 102 | ||||
| -rw-r--r-- | lib/Music.hs | 8 | ||||
| -rw-r--r-- | src/Bottom.hs | 11 | ||||
| -rw-r--r-- | src/Emacs.hs | 10 | ||||
| -rw-r--r-- | src/Single.hs | 48 | ||||
| -rw-r--r-- | src/Sway.hs | 17 | ||||
| -rw-r--r-- | xmobar-config.cabal | 7 | 
9 files changed, 123 insertions, 140 deletions
| diff --git a/lib/Attic.hs b/lib/Attic.hs new file mode 100644 index 0000000..3697b82 --- /dev/null +++ b/lib/Attic.hs @@ -0,0 +1,51 @@ +module Attic 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 + +data CombinedMonitor a b = CombinedMonitor a b (String -> String -> String) + +instance (Show a, Show b) => Show (CombinedMonitor a b) where +  show (CombinedMonitor a b _) = "Alt (" ++ show a ++ ") (" ++ show b ++ ")" + +instance (Read a, Read b) => Read (CombinedMonitor a b) where +  readsPrec _ = undefined + +instance (Exec a, Exec b) => Exec (CombinedMonitor a b) where +  alias (CombinedMonitor a b _) = alias a ++ "_" ++ alias b +  rate (CombinedMonitor a b _) = min (rate a) (rate b) +  start (CombinedMonitor a b comb) cb +    = startMonitors a b (\s t -> cb $ comb s t) + +startMonitors a b cmb =  do +    sta <- newTVarIO "" +    stb <- newTVarIO "" +    _ <- async $ start a (atomically . writeTVar sta) +    _ <- async $ start b (atomically . writeTVar stb) +    go sta stb +      where go sta' stb' = do +              s <- readTVarIO sta' +              t <- readTVarIO stb' +              cmb s t +              tenthSeconds $ min (rate b) (rate a) +              go sta' stb' + +guardedMonitor a p = CombinedMonitor (PipeReader p (alias a ++ "_g")) a f +  where f s t = if null s || head s == '0' then "" else t + +altMonitor a b = CombinedMonitor a b (\s t -> if null s then t else s) +concatMonitor sep a b = CombinedMonitor a b (\s t -> s ++ sep ++ t) +toggleMonitor path a = altMonitor (guardedMonitor a path) + +-- compMPD p = concatMonitor " " mpd (autoMPD "150" (pIsLight p)) +-- alt x p = altMonitor (mpris p x 165) (compMPD p) + +-- config cl p = +--   if cl == "mpd" +--   then mpdConfig p +--   else Bottom.config [Run (alt cl p)] "|mpris2_mpd_autompd|" p diff --git a/lib/Config.hs b/lib/Config.hs index 7e1b2bb..a388e1e 100644 --- a/lib/Config.hs +++ b/lib/Config.hs @@ -85,14 +85,7 @@ baseConfig p = defaultConfig {    , borderColor = pBorder p    , fgColor = pForeground p    , bgColor = pBackground p -  , additionalFonts = [ "xft:Symbola-9" -                      , "xft:Symbola-10" -                      , "xft:Symbola-11" -                      , "xft:Symbola-11" -                      , "xft:Symbola-12" -                      , "xft:FontAwesome-10" -                      , "xft:FontAwesome-9"] - +  , additionalFonts = ["FontAwesome 9"]    , border = NoBorder    , alpha = pAlpha p    , overrideRedirect = True diff --git a/lib/Monitors.hs b/lib/Monitors.hs index d154ec3..ddff5b4 100644 --- a/lib/Monitors.hs +++ b/lib/Monitors.hs @@ -8,40 +8,6 @@ import Control.Concurrent.STM  import qualified Data.Char as Char  import qualified Text.Printf as Printf -data CombinedMonitor a b = CombinedMonitor a b (String -> String -> String) - -instance (Show a, Show b) => Show (CombinedMonitor a b) where -  show (CombinedMonitor a b _) = "Alt (" ++ show a ++ ") (" ++ show b ++ ")" - -instance (Read a, Read b) => Read (CombinedMonitor a b) where -  readsPrec _ = undefined - -instance (Exec a, Exec b) => Exec (CombinedMonitor a b) where -  alias (CombinedMonitor a b _) = alias a ++ "_" ++ alias b -  rate (CombinedMonitor a b _) = min (rate a) (rate b) -  start (CombinedMonitor a b comb) cb -    = startMonitors a b (\s t -> cb $ comb s t) - -startMonitors a b cmb =  do -    sta <- atomically $ newTVar "" -    stb <- atomically $ newTVar "" -    _ <- async $ start a (atomically . writeTVar sta) -    _ <- async $ start b (atomically . writeTVar stb) -    go sta stb -      where go sta' stb' = do -              s <- readTVarIO sta' -              t <- readTVarIO stb' -              cmb s t -              tenthSeconds $ min (rate b) (rate a) -              go sta' stb' - -guardedMonitor a p = CombinedMonitor (PipeReader p (alias a ++ "_g")) a f -  where f s t = if null s || head s == '0' then "" else t - -altMonitor a b = CombinedMonitor a b (\s t -> if null s then t else s) -concatMonitor sep a b = CombinedMonitor a b (\s t -> s ++ sep ++ t) -toggleMonitor path a = altMonitor (guardedMonitor a path) -  topProc p = TopProc (p <~> ["-t" , "<mboth3>  <mboth2>  <mboth1> \                                     \ยท <both3>  <both2>  <both1>"                             , "-w", "10", "-L" , "10", "-H", "80"]) 15 @@ -80,32 +46,32 @@ uptime p = Uptime (p <~> [ "-t" , "<days> <hours>", "-m", "3", "-c", "0", "-S"  weather' tmp st p =    WeatherX st -           [ ("", fc (pDim p) (fn 4 "๐ก")) -           , ("clear", fn 4 "๐ฃ") -           , ("sunny", fc (pHigh p) $ fn 4 "๐ฃ") -           , ("fair", fn 4 "๐ฃ") -           , ("mostly clear", fn 4 "๐ค") -           , ("mostly sunny", fn 4 "๐ค") -           , ("partly sunny", fn 3 "โ
") -           , ("obscured", fn 4 "๐") -- ๐ซ -           , ("mist", fn 4 "๐") -           , ("cloudy", fn 3 "โ") -           , ("overcast", fn 3 "โ๏ธ") -           , ("partly cloudy", fn 3 "โ
") -           , ("mostly cloudy", fn 3 "โ๏ธ") -           , ("considerable cloudiness",  fn 3 "โ๏ธ") -           , ("light rain", fn 4 "๐ง") -           , ("rain", fn 4 "โ") -           , ("ice crystals", snow) -           , ("light snow", fn 3 "๐จ") -           , ("snow", snow) +           [ ("", "\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", "25", "-E", ".."] +           (mkArgs p ["-t", tmp , "-L", "10", "-H", "25" , "-T", "25", "-E", "โฆ"]                       ["-w", ""])             18000 -  where snow = fni "\xf2dc" -weather = weather' "<skyConditionS> <tempC>ยฐ <rh>% <windKmh> (<hour>)" +weather = weather' "<skyConditionS> <tempC>ยฐ  <windKmh> <weather>"  -- "https://wttr.in?format=" ++ fnn 3 "%c" ++ "+%t+%C+%w++" ++ fnn 1 "%m"  -- , Run (ComX "curl" [wttrURL "Edinburgh"] "" "wttr" 18000) @@ -128,9 +94,9 @@ batt p =             , "-P"             , "-a", "notify-send -u critical 'Battery running out!!!!!!'"             , "-A", "7" -           , "-i", fn 2 "\9211" -           , "-O", fn 2 " \9211" ++ " <timeleft> <watts>" -           , "-o", fn 2 " ๐" ++ " <timeleft> <watts>" +           , "-i", fn 1 "\9211" +           , "-O", fn 1 " \9211" ++ " <timeleft> <watts>" +           , "-o", fn 1 " ๐" ++ " <timeleft> <watts>"             , "-H", "10", "-L", "7"             , "-h", pHigh p, "-l", pLow p] 50 "batt0" @@ -140,15 +106,15 @@ iconBatt p =             , "-S", "Off", "-d", "0", "-m", "2"             , "-L", "10", "-H", "90", "-p", "2"             , "-W", "0", "-f", -             "\xf244\xf243\xf243\xf243\xf242\xf242\xf242\xf241\xf241\xf240" +             "\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", fni "\xf011" -           , "-O", fni "\xf1e6  <leftbar>" ++ " <left> <watts> <timeleft>" -           , "-o", fni "<leftbar>" ++ " <left> <watts> <timeleft>" +           , "-i", fn 1 "\xf011" +           , "-O", fn 1 "\xf1e6  <leftbar>" ++ " <left> <watts> <timeleft>" +           , "-o", fn 1 "<leftbar>" ++ " <left> <watts> <timeleft>"             , "-H", "10", "-L", "7"             , "-h", pHigh p, "-l", pLow p] 50 "batt0" @@ -202,18 +168,22 @@ mail p = MailX [ ("I", "jao/inbox", pHigh 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", "<status> <volume>"                    , "--", "-C", pForeground p, "-c", "#8b4726" -                  , "-O", fni "\xf025" -- "\xf130" fn 4 "๐ง" -                  , "-o", fn 4 "๐" +                  , "-O", fn 1 "\xf025" +                  , "-o", fn 1 "\xf131"                    ] 10  captureVol = Volume "default" "Capture" ["-t", "<volume>"] 10  kbd p = Kbd [("us", ""), ("us(intl)", kbi pHigh)] -- kbi pDim -  where kbi a = fc (a p) (fni " \xf11c") +  where kbi a = fc (a p) (fn 1 " \xf11c")  brightness = Brightness ["--", "-D", "intel_backlight"] 10  brightness' = Brightness ["--", "-D", "amdgpu_bl0", "-C", "brightness"] 10 diff --git a/lib/Music.hs b/lib/Music.hs index 7f0215a..3b7bec4 100644 --- a/lib/Music.hs +++ b/lib/Music.hs @@ -41,11 +41,3 @@ mpdConfig p =    {    textOffsets = [defaultHeight - 7, defaultHeight - 6]    } - -compMPD p = concatMonitor " " mpd (autoMPD "150" (pIsLight p)) -alt x p = altMonitor (mpris p x 165) (compMPD p) - -config cl p = -  if cl == "mpd" -  then mpdConfig p -  else Bottom.config [Run (alt cl p)] "|mpris2_mpd_autompd|" p diff --git a/src/Bottom.hs b/src/Bottom.hs deleted file mode 100644 index 92e2d3e..0000000 --- a/src/Bottom.hs +++ /dev/null @@ -1,11 +0,0 @@ -import Xmobar -import Config -import qualified Music - -import System.Environment (getArgs) - - -main :: IO () -main = do -  args <- getArgs -  palette >>= configFromArgs . Music.config "spotify" >>= xmobar diff --git a/src/Emacs.hs b/src/Emacs.hs index adbe13c..5c6cb26 100644 --- a/src/Emacs.hs +++ b/src/Emacs.hs @@ -70,10 +70,8 @@ weath st p =             18000  config p = (baseConfig p) { -  position = TopSize C 100 (defaultHeight - 2) -  , textOutput = True -  , textOutputFormat = Ansi -  , font = "xft:DejaVu Sans Mono-8" +  position = TopSize C 100 22 +  , font = "Hack 10"    , commands = [ Run (topProcL p)                 , Run (batt0 p)                 , Run (cpu p) @@ -94,8 +92,8 @@ config p = (baseConfig p) {                 , Run (weath "EGPH" p)                 ]    , template = " |batt0| " -             -- ++ " ๐ง |wg-mullvad||tun0||wlp164s0wi|" -             ++ "  |wg-mullvad||tun0||wlp164s0wi|" +             ++ " ๐ง |wg-mullvad||tun0||wlp164s0wi|" +             -- ++ "  |wg-mullvad||tun0||wlp164s0wi|"               ++ " |dynnetwork| "               ++ "  |default:Master| ๐๏ธ |default:Capture|"               ++ "  |EGPH|" diff --git a/src/Single.hs b/src/Single.hs index 44dd6f7..e7ecee6 100644 --- a/src/Single.hs +++ b/src/Single.hs @@ -2,10 +2,11 @@ import Xmobar  import Config  import Monitors -topProcL p = TopProc (p <~> args) 15 -  where template = "<both1>  <both2>  <both3>  <both4> " -                 ++ "ยท  <mboth1>  <mboth2>  <mboth3>  <mboth4>" -        args = ["-t", template, "-w", "12", "-L" , "10", "-H", "80"] +topProcL p s = TopProc (p <~> args) 15 +  where temp | s = "<both1>  <both2>  <both3> ยท  <mboth1>  <mboth2>  <mboth3>" +             | otherwise = "<both1>  <both2>  <both3>  <both4> " +                            ++ "ยท  <mboth1>  <mboth2>  <mboth3>  <mboth4>" +        args = ["-t", temp, "-w", "12", "-L" , "10", "-H", "80"]  diskIOS p = DiskIO [("/", "<read> <write>")] (diskArgs p) 10 @@ -16,18 +17,18 @@ memory' = Memory args 20    where template = "<used> <available>"          args = ["-t", template , "-p", "2", "-d", "1", "--", "--scale", "1024"] -master on off p = Volume "default" "Master" (args ++ ("--":ext)) 10 -  where args = ["-t", "<status> <volume>"] -        ext = ["-C", pForeground p, "-c", "sienna4", "-O", on, "-o", off] -  config p = (baseConfig p) { -  position = TopSize C 100 (defaultHeight - 2) -  , textOffset = offset -  , textOffsets = [offset - 1, offset - 1, offset + 2 , offset, offset + 1] -  , bgColor = if pIsLight p then "gray94" else "black" -  , alpha = 255 +  position = TopSize C 100 24 +  , bgColor = if pIsLight p then "#f0f0f0" else "black" +  , alpha = 233    , border = FullB -  , commands = [ Run (topProcL p) +  , textOffsets = [] +  , textOffset = 0 +  , iconOffset = 0 +  -- , font = "Source Code Pro, Noto Color Emoji Regular 9, Italic 9" +  -- , font = "DejaVu Sans Mono, Noto Color Emoji 9, Regular 9" +  , font = "Hack, Noto Color Emoji Regular 9, Light 9" +  , commands = [ Run (topProcL p isXmonad)                 , Run (load p)                 , Run (iconBatt p)                 , Run (cpuBars p) @@ -40,26 +41,29 @@ config p = (baseConfig p) {                 , Run (dynNetwork p)                 , Run (vpnMark "wg-mullvad")                 , Run tun0 -               , Run (master (dimi "\xf025") (dimi "\xf131") p) +               , Run (masterVol p)                 , Run captureVol                 , Run laTime                 , Run localTime                 , Run (cpuFreq' p) -               , Run (weather' wt "EGPH" p) +               , Run (weather "EGPH" p) +               -- , Run nmmail                 ] ++ extraCmds    , template = trayT               ++ " |batt0| "               ++ "<action=`toggle-app.sh nm-applet`>" -             ++ "  |wg-mullvad||tun0||wlp164s0wi|" +             ++ "  <fc=#000000>|wg-mullvad||tun0||wlp164s0wi|</fc>"               ++ "</action>"               ++ " |dynnetwork| "               ++ "<action=`toggle-app.sh pasystray`>"               ++ "  |default:Master| " ++ dimi "\xf130" ++ " |default:Capture|"               ++ "</action>" -             ++ "    |EGPH| " +             ++ "    |EGPH|" +             -- ++ fc "sienna4" " |mail|" +             ++ " |kbd|" +             ++ "{"               ++ eLog p -             ++ " {} " -             ++ "|kbd|" +             ++ "}"               ++ " |multicpu|"               ++ "  |cpufreq|"               ++ " |multicoretemp|" @@ -68,9 +72,7 @@ config p = (baseConfig p) {               ++ dimi "\xf0a0" ++ "|diskio| |disku| "               ++ "  |datetime| "               ++ " |laTime| " -  } where dimi = fc "grey50" . fn 7 -          offset = defaultHeight - 8 -          wt = "<skyConditionS> <tempC>ยฐ  <windKmh>" ++ fn 5 "๐ซ" ++ " <weather>" +  } where dimi = fc "grey40" . fn 1            isXmonad = pWm p == Just "xmonad"            trayT = if isXmonad then "|tray|" else ""            eLog p = if isXmonad then "|XMonadLog|" else fc (pHigh p) "|elog|" diff --git a/src/Sway.hs b/src/Sway.hs index 4c197ab..5c7ecc2 100644 --- a/src/Sway.hs +++ b/src/Sway.hs @@ -21,21 +21,11 @@ mprisx client width =                  , "-T", show width                  , "-E", "โฆ", "-M", "100", "-x", ""] 40 - -nmmail = NotmuchMail "mail" [MailItem "" "" "tag:new"] 100 -  config p = (baseConfig p) {    position = TopSize C 100 (defaultHeight - 1)    , textOutput = True    , textOutputFormat = Swaybar    , font = "Source Code Pro Medium 9" -  , additionalFonts = [ "xft:Symbola 9" -                      , "xft:Symbola 10" -                      , "xft:Symbola 11" -                      , "xft:Symbola 11" -                      , "xft:DejaVu Sans Mono 9" -                      , "xft:FontAwesome 10" -                      , "xft:FontAwesome 9"]    , bgColor = "#ffffffc0"    , fgColor = "#000000"    , border = FullB @@ -61,24 +51,29 @@ config p = (baseConfig p) {                 , Run (PipeReader ":/tmp/emacs.status" "estat")                 , Run nmmail                 ] -  , template = fc "#a0522d" "|mail| |estat|" +  , template = fc "#a0522d" "|mail| |estat|  "               ++ " |batt0| " +             ++ "   "               ++ "<action=`toggle-app.sh nm-applet --indicator`>"               ++ " |wg-mullvad||tun0||wlp164s0wi|"               ++ "</action>"               ++ " |dynnetwork| " +             ++ "<hspace=3/>"               ++ "<action=`toggle-app.sh pavucontrol`>"               ++ "  |default:Master| "               ++ fn 7 "\xf130" ++ " |default:Capture|"               ++ "</action>  "               ++  "|mpd|" +             ++ "<hspace=3/>"               ++ "   |EGPH| "               ++ " {} <hspace=3/>"               ++ "|multicpu| "               ++ "|multicoretemp| "               ++ " |top|   " +             ++ "<hspace=1/>"               ++ fni "โธ" ++ " |memory| "               ++ " |diskio| |disku| " +             ++ "<hspace=3/>"               ++ " |datetime| "               ++ " |laTime|  "    } where dimi = fc (pDim p) diff --git a/xmobar-config.cabal b/xmobar-config.cabal index f1dccac..ef64410 100644 --- a/xmobar-config.cabal +++ b/xmobar-config.cabal @@ -41,13 +41,6 @@ executable xmobar-top    build-depends: base, xmobar, xmobar-config    default-language: Haskell2010 -executable xmobar-bottom -  main-is: Bottom.hs -  hs-source-dirs: src -  ghc-options: -rtsopts -with-rtsopts=-V0  -threaded -  build-depends: base, xmobar, xmobar-config -  default-language: Haskell2010 -  executable xmobar-sway    main-is: Sway.hs    hs-source-dirs: src | 
