From 0b8f1901f6e955fb1f0f42b0b6b598bbf8a2ae12 Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 8 Dec 2018 02:39:19 +0000 Subject: Unifying MPD and Mpris in a single exec --- src/Bottom.hs | 14 ++++++++++++++ src/MPD.hs | 27 --------------------------- src/Mpris.hs | 20 -------------------- src/lib/Bottom.hs | 2 +- src/lib/MPD.hs | 26 ++++++++++++++++++++++++++ src/lib/Mpris.hs | 20 ++++++++++++++++++++ xmobar-config.cabal | 13 +++---------- 7 files changed, 64 insertions(+), 58 deletions(-) create mode 100644 src/Bottom.hs delete mode 100644 src/MPD.hs delete mode 100644 src/Mpris.hs create mode 100644 src/lib/MPD.hs create mode 100644 src/lib/Mpris.hs diff --git a/src/Bottom.hs b/src/Bottom.hs new file mode 100644 index 0000000..bfc4ecb --- /dev/null +++ b/src/Bottom.hs @@ -0,0 +1,14 @@ +import Xmobar +import Config +import qualified MPD +import qualified Mpris + +import System.Environment (getArgs) + +main :: IO () +main = do + args <- getArgs + let mpris = if null args then "spotify" else head args + if mpris == "mpd" + then palette >>= xmobar . MPD.config + else palette >>= xmobar . (Mpris.config mpris) diff --git a/src/MPD.hs b/src/MPD.hs deleted file mode 100644 index d237867..0000000 --- a/src/MPD.hs +++ /dev/null @@ -1,27 +0,0 @@ -import Xmobar -import Config (palette) -import qualified Bottom (config) - -mpd = MPD [ "-W", "12", "-b", "░", "-f", "▒", "-t" - , " "] 10 - -autoMPD = AutoMPD [ "-T", "160", "-E", "...", "-W", "10", "-t" - , " / \ - \</fc></fn> \ - \<fn=0><album></fn> \ - \<fn=0><fc=dodgerblue4><artist></fc> \ - \<fc=burlywood4><composer></fc> <date></fn>"] - - -config p = (Bottom.config [(Run mpd), (Run autoMPD)] p) { - template = "|kbd||default:Master| |default:Capture| \ - \|mpd| |autompd| {} |mbox| \ - \|EGPH| \ - \|diskio| |disku| · |bright| · |coretemp| \ - \|memory| · |uptime| |b0| " - , additionalFonts = ["xft:Hack-7"] - , textOffsets = [17] - } - -main :: IO () -main = palette >>= xmobar . config diff --git a/src/Mpris.hs b/src/Mpris.hs deleted file mode 100644 index 09c155d..0000000 --- a/src/Mpris.hs +++ /dev/null @@ -1,20 +0,0 @@ -import Xmobar -import Config (palette) -import qualified Bottom (config) - -mpris = - Mpris2 "spotify" -- "clementine" -- - ["-t", " <tracknumber>\ - \ <title> <fc=sienna4><artist></fc>\ - \ <album> <length>" - , "-T", "180", "-E", "...", "-M", "100", "-x", ""] 10 - -config p = (Bottom.config [Run mpris] p) { - template = "|kbd||default:Master| |default:Capture| \ - \|mpris2| {} |mbox| \ - \|EGPH| \ - \|diskio| |disku| · |bright| · |coretemp| \ - \|memory| · |uptime| |b0| " - } -main :: IO () -main = palette >>= xmobar . config diff --git a/src/lib/Bottom.hs b/src/lib/Bottom.hs index 4bd6614..0c6a372 100644 --- a/src/lib/Bottom.hs +++ b/src/lib/Bottom.hs @@ -54,7 +54,7 @@ masterVol = Volume "default" "Master" ["-t", "<status> <volume>" , "--", "-C", "black", "-c", "sienna4", "-O", "" - , "-o", "×"] 10 + , "-o", " ×"] 10 captureVol = Volume "default" "Capture" ["-t", "<volume>"] 10 diff --git a/src/lib/MPD.hs b/src/lib/MPD.hs new file mode 100644 index 0000000..be09f5f --- /dev/null +++ b/src/lib/MPD.hs @@ -0,0 +1,26 @@ +module MPD where + +import Xmobar +import Config (palette) +import qualified Bottom (config) + +mpd = MPD [ "-W", "12", "-b", "░", "-f", "▒", "-t" + , " <lapsed> <fc=seashell3><fn=1><bar></fn></fc>"] 10 + +autoMPD = AutoMPD [ "-T", "160", "-E", "...", "-W", "10", "-t" + , "<length> <ppos>/<plength> \ + \<fn=0><fc=darkolivegreen><title></fc></fn> \ + \<fn=0><album></fn> \ + \<fn=0><fc=dodgerblue4><artist></fc> \ + \<fc=burlywood4><composer></fc> <date></fn>"] + + +config p = (Bottom.config [(Run mpd), (Run autoMPD)] p) { + template = "|kbd||default:Master| |default:Capture| \ + \|mpd| |autompd| {} |mbox| \ + \|EGPH| \ + \|diskio| |disku| · |bright| · |coretemp| \ + \|memory| · |uptime| |b0| " + , additionalFonts = ["xft:Hack-7"] + , textOffsets = [17] + } diff --git a/src/lib/Mpris.hs b/src/lib/Mpris.hs new file mode 100644 index 0000000..1936d57 --- /dev/null +++ b/src/lib/Mpris.hs @@ -0,0 +1,20 @@ +module Mpris where + +import Xmobar +import Config (palette) +import qualified Bottom (config) + +mpris client = + Mpris2 client -- "clementine" -- + ["-t", " <tracknumber>\ + \ <title> <fc=sienna4><artist></fc>\ + \ <album> <length>" + , "-T", "180", "-E", "...", "-M", "100", "-x", ""] 10 + +config client p = (Bottom.config [Run (mpris client)] p) { + template = "|kbd||default:Master| |default:Capture| \ + \|mpris2| {} |mbox| \ + \|EGPH| \ + \|diskio| |disku| · |bright| · |coretemp| \ + \|memory| · |uptime| |b0| " + } diff --git a/xmobar-config.cabal b/xmobar-config.cabal index a255014..4ab8d73 100644 --- a/xmobar-config.cabal +++ b/xmobar-config.cabal @@ -13,7 +13,7 @@ extra-source-files: library hs-source-dirs: src/lib - exposed-modules: Config, Bottom + exposed-modules: Config, Bottom, Mpris, MPD build-depends: base >=4.7 && <5, xmobar other-modules: Paths_xmobar_config @@ -26,15 +26,8 @@ executable xmobar-top build-depends: base, xmobar, xmobar-config default-language: Haskell2010 -executable xmobar-mpris - main-is: Mpris.hs - hs-source-dirs: src - ghc-options: -rtsopts -with-rtsopts=-V0 - build-depends: base, xmobar, xmobar-config - default-language: Haskell2010 - -executable xmobar-mpd - main-is: MPD.hs +executable xmobar-bottom + main-is: Bottom.hs hs-source-dirs: src ghc-options: -rtsopts -with-rtsopts=-V0 build-depends: base, xmobar, xmobar-config -- cgit v1.2.3