diff options
| -rwxr-xr-x | extras/HOME/.local/bin/media-control (renamed from extras/HOME/.local/bin/spotify-control) | 0 | ||||
| -rw-r--r-- | extras/HOME/.xmobarrc | 2 | ||||
| -rwxr-xr-x | extras/HOME/.xmonad/xmobar-media | 2 | ||||
| -rw-r--r-- | src/Rahm/Desktop/Keys.hs | 6 | ||||
| -rw-r--r-- | xmobar/extras/weather/src/Main.hs | 101 |
5 files changed, 58 insertions, 53 deletions
diff --git a/extras/HOME/.local/bin/spotify-control b/extras/HOME/.local/bin/media-control index 34a2633..34a2633 100755 --- a/extras/HOME/.local/bin/spotify-control +++ b/extras/HOME/.local/bin/media-control diff --git a/extras/HOME/.xmobarrc b/extras/HOME/.xmobarrc index ffe7957..62efc0a 100644 --- a/extras/HOME/.xmobarrc +++ b/extras/HOME/.xmobarrc @@ -34,7 +34,7 @@ Config \%UnsafeStdinReader%}{\ \<fc=#404040>\ \<action=alacritty -t 'Floating Term' -e sh -c 'curl wttr.in ; read i'>\ - \%weather% \ + \<fc=#888888>|</fc> %weather% \ \</action>\ \</fc><fc=#a0a0a0>%media%</fc>\ \%bluetooth% %bat%<fn=3> %cpu% %memory%<fc=#8888ff> %time%</fc></fn> ", diff --git a/extras/HOME/.xmonad/xmobar-media b/extras/HOME/.xmonad/xmobar-media index 8855ea9..bdedc8d 100755 --- a/extras/HOME/.xmonad/xmobar-media +++ b/extras/HOME/.xmonad/xmobar-media @@ -1,6 +1,6 @@ #!/bin/bash -title="$(spotify-control getTitle)" +title="$(media-control getTitle)" ntitle=${#title} if [[ "$ntitle" -gt 40 ]] ; then title="${title:0:36} ..." diff --git a/src/Rahm/Desktop/Keys.hs b/src/Rahm/Desktop/Keys.hs index b136c62..c0d9c3a 100644 --- a/src/Rahm/Desktop/Keys.hs +++ b/src/Rahm/Desktop/Keys.hs @@ -173,11 +173,11 @@ decreaseVolume = spawnX "pactl set-sink-volume @DEFAULT_SINK@ -5%" increaseVolume = spawnX "pactl set-sink-volume @DEFAULT_SINK@ +5%" -playPause = spawnX "spotify-control play" +playPause = spawnX "media-control play" -mediaPrev = spawnX "spotify-control prev" +mediaPrev = spawnX "media-control prev" -mediaNext = spawnX "spotify-control next" +mediaNext = spawnX "media-control next" decreaseVolumeDoc = doc "Decrease volume" decreaseVolume diff --git a/xmobar/extras/weather/src/Main.hs b/xmobar/extras/weather/src/Main.hs index aa5a408..ccabc21 100644 --- a/xmobar/extras/weather/src/Main.hs +++ b/xmobar/extras/weather/src/Main.hs @@ -11,6 +11,7 @@ import Data.Aeson import Data.Aeson.Types (Parser) import qualified Data.ByteString.Lazy.Char8 import qualified Data.Char +import Data.List (isInfixOf) import qualified Data.Map import Data.Maybe (fromMaybe) import qualified Data.Text @@ -22,21 +23,21 @@ import Text.Printf (printf) -- Date time that easily comparable. data SillyTime = SillyTime - { sillyTimeDate :: String, - sillyTimeAMPM :: String, - sillyTimeTime :: String + { sillyTimeDate :: !String, + sillyTimeAMPM :: !String, + sillyTimeTime :: !String } deriving (Ord, Eq, Show) data CurrentCondition = CurrentCondition - { feelsLikeF :: String, - cloudCover :: String, - humidity :: String, - tempF :: String, - weatherDesc :: String, - windspeedMiles :: String, - winddir :: String, - observationTime :: SillyTime + { feelsLikeF :: !String, + cloudCover :: !String, + humidity :: !String, + tempF :: !String, + weatherDesc :: !String, + windspeedMiles :: !String, + winddir :: !String, + observationTime :: !SillyTime } deriving (Generic, Show) @@ -46,15 +47,15 @@ newtype NearestArea = NearestArea deriving (Generic, Show) data Astronomy = Astronomy - { sunrise :: SillyTime, - sunset :: SillyTime + { sunrise :: !SillyTime, + sunset :: !SillyTime } deriving (Generic, Show) data Weather = Weather - { currentCondition :: CurrentCondition, - nearestArea :: NearestArea, - astronomy :: Astronomy + { currentCondition :: !CurrentCondition, + nearestArea :: !NearestArea, + astronomy :: !Astronomy } deriving (Generic, Show) @@ -118,39 +119,38 @@ instance FromJSON Weather where =<< getFirst (v .: "weather") ) -conditionsIconDay :: Data.Map.Map String String +conditionsIconDay :: [(String -> Bool, String)] conditionsIconDay = - Data.Map.fromList - [ ("overcast", fc "#808080" "\63070"), - ("fair", fc "a0a0a0" "š"), - ("clear", fc "#ddcf04" "\58125"), - ("sunny", fc "#ddcf04" "\58125"), - ("mostly clear", fc "#00a3c4" "\57894"), - ("mostly sunny", fc "#ddcf04" "\58124"), - ("partly sunny", fc "#ddcf04" "\58124"), - ("fair", fc "#a0a0a0" "\127761"), - ("cloudy", fc "#a0a0a0" "\64143"), - ("overcast", fc "#808080" "\63070"), - ("partly cloudy", fc "#a0a0a0" "\64148"), - ("mostly cloudy", fc "#808080" "\63070"), - ("considerable cloudiness", fc "#a0a0a0" "\64381") - ] - -conditionsIconNight :: Data.Map.Map String String + [ ((== "overcast"), fc "#808080" "\63070"), + ((== "fair"), fc "a0a0a0" "š"), + ((== "clear"), fc "#ddcf04" "\58125"), + ((== "sunny"), fc "#ddcf04" "\58125"), + ((== "mostly clear"), fc "#00a3c4" "\57894"), + ((== "mostly sunny"), fc "#ddcf04" "\58124"), + ((== "partly sunny"), fc "#ddcf04" "\58124"), + ((== "fair"), fc "#a0a0a0" "\127761"), + ((== "cloudy"), fc "#a0a0a0" "\64143"), + ((== "overcast"), fc "#808080" "\63070"), + ((== "partly cloudy"), fc "#a0a0a0" "\64148"), + ((== "mostly cloudy"), fc "#808080" "\63070"), + ((== "considerable cloudiness"), fc "#a0a0a0" "\64381"), + (("snow" `isInfixOf`), fc "#a0a0f0" "\58138") + ] + +conditionsIconNight :: [(String -> Bool, String)] conditionsIconNight = - Data.Map.fromList - [ ("clear", fc "#00a3c4" "\61830"), - ("sunny", fc "#00a3c4" "\61830"), - ("mostly clear", fc "#00a3c4" "\57894"), - ("mostly sunny", fc "#00a3c4" "\57894"), - ("partly sunny", fc "#00a3c4" "\57894"), - ("fair", fc "#808080" "\127761"), - ("cloudy", fc "#808080" "\64143"), - ("overcast", fc "#404040" "\63070"), - ("partly cloudy", fc "#a0a0a0" "\57894"), - ("mostly cloudy", fc "#808080" "\63070"), - ("considerable cloudiness", fc "#a0a0a0" "\64381") - ] + [ ((== "clear"), fc "#00a3c4" "\61830"), + ((== "sunny"), fc "#00a3c4" "\61830"), + ((== "mostly clear"), fc "#00a3c4" "\57894"), + ((== "mostly sunny"), fc "#00a3c4" "\57894"), + ((== "partly sunny"), fc "#00a3c4" "\57894"), + ((== "fair"), fc "#808080" "\127761"), + ((== "cloudy"), fc "#808080" "\64143"), + ((== "overcast"), fc "#404040" "\63070"), + ((== "partly cloudy"), fc "#a0a0a0" "\57894"), + ((== "mostly cloudy"), fc "#808080" "\63070"), + ((== "considerable cloudiness"), fc "#a0a0a0" "\64381") + ] handleWeather :: Weather -> String handleWeather w = execWriter $ do @@ -186,7 +186,7 @@ handleWeather w = execWriter $ do tell $ fn 5 $ fromMaybe "?" $ - Data.Map.lookup (map Data.Char.toLower $ weatherDesc (currentCondition w)) conditions + findMatch (map Data.Char.toLower $ weatherDesc (currentCondition w)) conditions tell " " tell $ lightGrey $ fn 3 $ printf "%s°F" (tempF $ currentCondition w) @@ -203,6 +203,11 @@ handleWeather w = execWriter $ do fc :: String -> String -> String fc = printf "<fc=%s>%s</fc>" +findMatch :: a -> [(a -> Bool, b)] -> Maybe b +findMatch a ((f, b) : fs) | f a = Just b +findMatch a (_ : fs) = findMatch a fs +findMatch _ [] = Nothing + main :: IO () main = do (code, resp) <- curlGetString "https://wttr.in?format=j2" [] |