From c300eff998d758bf867abbb7f39bf6fdfecf7a2e Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 4 Nov 2022 23:58:06 +0000 Subject: cleanups and unused code removed --- lib/Attic.hs | 51 ++++++++++++++++++++++++++ lib/Config.hs | 9 +---- lib/Monitors.hs | 102 +++++++++++++++++++--------------------------------- lib/Music.hs | 8 ----- src/Bottom.hs | 11 ------ src/Emacs.hs | 10 +++--- src/Single.hs | 48 +++++++++++++------------ src/Sway.hs | 17 ++++----- xmobar-config.cabal | 7 ---- 9 files changed, 123 insertions(+), 140 deletions(-) create mode 100644 lib/Attic.hs delete mode 100644 src/Bottom.hs 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" , " \ \ยท " , "-w", "10", "-L" , "10", "-H", "80"]) 15 @@ -80,32 +46,32 @@ uptime p = Uptime (p <~> [ "-t" , " ", "-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' " ยฐ % ()" +weather = 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" ++ " " - , "-o", fn 2 " ๐Ÿ”‹" ++ " " + , "-i", fn 1 "\9211" + , "-O", fn 1 " \9211" ++ " " + , "-o", fn 1 " ๐Ÿ”‹" ++ " " , "-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 " ++ " " - , "-o", fni "" ++ " " + , "-i", fn 1 "\xf011" + , "-O", fn 1 "\xf1e6 " ++ " " + , "-o", fn 1 "" ++ " " , "-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", " " , "--", "-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", ""] 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 = " " - ++ "ยท " - args = ["-t", template, "-w", "12", "-L" , "10", "-H", "80"] +topProcL p s = TopProc (p <~> args) 15 + where temp | s = " ยท " + | otherwise = " " + ++ "ยท " + args = ["-t", temp, "-w", "12", "-L" , "10", "-H", "80"] diskIOS p = DiskIO [("/", " ")] (diskArgs p) 10 @@ -16,18 +17,18 @@ memory' = Memory args 20 where template = " " args = ["-t", template , "-p", "2", "-d", "1", "--", "--scale", "1024"] -master on off p = Volume "default" "Master" (args ++ ("--":ext)) 10 - where args = ["-t", " "] - 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| " ++ "" - ++ " |wg-mullvad||tun0||wlp164s0wi|" + ++ " |wg-mullvad||tun0||wlp164s0wi|" ++ "" ++ " |dynnetwork| " ++ "" ++ " |default:Master| " ++ dimi "\xf130" ++ " |default:Capture|" ++ "" - ++ " |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 = " ยฐ " ++ fn 5 "๐ŸŒซ" ++ " " + } 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| " + ++ " " ++ "" ++ " |wg-mullvad||tun0||wlp164s0wi|" ++ "" ++ " |dynnetwork| " + ++ "" ++ "" ++ " |default:Master| " ++ fn 7 "\xf130" ++ " |default:Capture|" ++ " " ++ "|mpd|" + ++ "" ++ " |EGPH| " ++ " {} " ++ "|multicpu| " ++ "|multicoretemp| " ++ " |top| " + ++ "" ++ fni "โ˜ธ" ++ " |memory| " ++ " |diskio| |disku| " + ++ "" ++ " |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 -- cgit v1.2.3