From ea44b017950cbab49a68959190ab0a859d45e7b1 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Thu, 4 Nov 2021 17:52:47 -0600 Subject: Clean up spotify-control script. --- extras/HOME/.local/bin/spotify-control | 50 +++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/extras/HOME/.local/bin/spotify-control b/extras/HOME/.local/bin/spotify-control index 751f562..e001eb6 100755 --- a/extras/HOME/.local/bin/spotify-control +++ b/extras/HOME/.local/bin/spotify-control @@ -12,27 +12,63 @@ then exit fi +function mpris2_dbus_player_do { + dbus-send \ + --print-reply \ + --dest=org.mpris.MediaPlayer2.spotify \ + /org/mpris/MediaPlayer2 \ + "org.mpris.MediaPlayer2.Player.$1" +} + +function mpris2_dbus_get_player_property { + dbus-send \ + --print-reply \ + --dest=org.mpris.MediaPlayer2.spotify \ + /org/mpris/MediaPlayer2 \ + org.freedesktop.DBus.Properties.Get \ + string:'org.mpris.MediaPlayer2.Player' "string:$1" +} + case $1 in "play") - dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause + mpris2_dbus_player_do PlayPause ;; "next") - dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next + mpris2_dbus_player_do Next ;; "prev") - dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous + mpris2_dbus_player_do Previous ;; "getTitle") - dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 1 "title"|egrep -v "title"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$ + mpris2_dbus_get_player_property 'Metadata' | \ + egrep -A 1 "title" | \ + egrep -v "title" | \ + cut -b 44- | \ + cut -d '"' -f 1 | \ + egrep -v ^$ ;; "getArtist") - dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "artist"|egrep -v "artist"|egrep -v "array"|cut -b 27-|cut -d '"' -f 1|egrep -v ^$ + mpris2_dbus_get_player_property 'Metadata' | \ + -A 2 "artist" | \ + egrep -v "artist" | \ + egrep -v "array" | \ + cut -b 27- | \ + cut -d '"' -f 1 | \ + egrep -v ^$ ;; "getAlbum") - dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "album"|egrep -v "album"|egrep -v "array"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$ + mpris2_dbus_get_player_property 'Metadata' | \ + egrep -A 2 "album" | \ + egrep -v "album" | \ + egrep -v "array" | \ + cut -b 44- | \ + cut -d '"' -f 1 | \ + egrep -v ^$ ;; "getStatus") - dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|grep 'string "[^"]*"'|sed 's/.*"\(.*\)"[^"]*$/\1/' + mpris_dbus_get_player_property 'PlaybackStatus' | \ + grep 'string "[^"]*"' | \ + sed 's/.*"\(.*\)"[^"]*$/\1/' ;; *) echo "Unknown command: " $1 -- cgit From efef2ad31b0a1ce7ebcc2a635114f5a1d3f82ec8 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Mon, 8 Nov 2021 01:02:01 -0700 Subject: minor fixes and whatnot --- extras/HOME/.xmobarrc | 4 ++-- extras/HOME/.xmonad/xmobar-weather | 9 +++------ src/Internal/Layout.hs | 19 ++++++++++--------- src/Main.hs | 2 +- stack.yaml | 2 +- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/extras/HOME/.xmobarrc b/extras/HOME/.xmobarrc index e2a3e9f..916ba21 100644 --- a/extras/HOME/.xmobarrc +++ b/extras/HOME/.xmobarrc @@ -2,7 +2,7 @@ Config { font = "xft:Monofur Nerd Font:size=12" , additionalFonts = [ "xft:Monofur bold Nerd Font:style=bold:size=12", - "xft:Monofur Nerd Font:size=9", + "xft:Monofur Bold Nerd Font:size=9", "xft:Monofur Nerd Font:size=9", "xft:Monofur Nerd Font:size=6", "xft:Monofur bold Nerd Font:size=15", @@ -30,7 +30,7 @@ Config , template = " %logo% %uname% │\ \ %date% │ \ - \%StdinReader%}%time%\ + \%StdinReader%}%time%\ \{ %cpu% %memory% \ \│ %weather% │\ \ %mpris2% │ \ diff --git a/extras/HOME/.xmonad/xmobar-weather b/extras/HOME/.xmonad/xmobar-weather index d9dc88b..e8ce28e 100755 --- a/extras/HOME/.xmonad/xmobar-weather +++ b/extras/HOME/.xmonad/xmobar-weather @@ -1,18 +1,16 @@ #!/usr/bin/perl -use LWP::Simple; use Time::Local; use POSIX; -$content = get("https://ipinfo.io"); +$content = `curl https://ipinfo.io`; die "Unable to get IP info" unless defined $content; ($city, $lat, $lon) = ($content =~ m/.*"city":\s+"([^"]+)".*"loc":\s+"(-?[0-9.]+),(-?[0-9.]+).*"/ims); -$content = get( - "https://api.sunrise-sunset.org/json?lat=$lat&lng=$lon&formatted=0"); +$content = `curl "https://api.sunrise-sunset.org/json?lat=$lat&lng=$lon&formatted=0"`; die "Unable to get sunrise/sunset data" unless defined $content; @@ -22,8 +20,7 @@ $sunrise_str =~ s#.*"sunrise":"([^"]*)".*#\1#; $sunset_str =~ s#.*"sunset":"([^"]*)".*#\1#; $current_str=strftime "%Y-%m-%dT%H:%M:%S+00:00", gmtime(); -$content = get( - "https://tgftp.nws.noaa.gov/data/observations/metar/decoded/KLMO.TXT"); +$content = `curl "https://tgftp.nws.noaa.gov/data/observations/metar/decoded/KLMO.TXT"`; die "Unable to get weather data" unless defined $content; diff --git a/src/Internal/Layout.hs b/src/Internal/Layout.hs index 632e912..4166b8f 100644 --- a/src/Internal/Layout.hs +++ b/src/Internal/Layout.hs @@ -38,7 +38,7 @@ myLayout = Grid ||| Dishes 2 (1/6) ||| (MosaicAlt M.empty :: MosaicAlt Window) ||| - (D.Dwindle D.R D.CW 1.5 1.1) + D.Dwindle D.R D.CW 1.5 1.1 data ModifyDescription m l a = ModifyDescription m (l a) deriving (Show, Read) @@ -82,18 +82,19 @@ instance DescriptionModifier TallDescriptionModifier Tall where instance DescriptionModifier ThreeColDescMod ThreeCol where newDescription _ (ThreeCol mast _ _) _ = "ThreeCol(" ++ show mast ++ ")" + newDescription _ (ThreeColMid mast _ _) _ = "ThreeColMid(" ++ show mast ++ ")" data ResizeZoom = ShrinkZoom | ExpandZoom deriving (Typeable) instance Message ResizeZoom where -data Flippable a = Flippable Bool -- True if flipped +newtype Flippable a = Flippable Bool -- True if flipped deriving (Show, Read) -data HFlippable a = HFlippable Bool -- True if flipped +newtype HFlippable a = HFlippable Bool -- True if flipped deriving (Show, Read) -data Rotateable a = Rotateable Bool -- True if rotated +newtype Rotateable a = Rotateable Bool -- True if rotated deriving (Show, Read) data FlipLayout = FlipLayout deriving (Typeable) @@ -137,7 +138,7 @@ instance (Eq a) => LayoutModifier Rotateable a where pureMess (Rotateable rot) mess = - fmap (\(DoRotate) -> Rotateable (not rot)) (fromMessage mess) + fmap (\DoRotate -> Rotateable (not rot)) (fromMessage mess) modifyDescription (Rotateable rot) underlying = let descr = description underlying in @@ -194,17 +195,17 @@ instance (Eq a) => LayoutModifier Zoomable a where (zoomed, rest) = partition ((==focused) . Just . fst) returned in case zoomed of [] -> return (rest, Nothing) - ((fwin, _):_) -> return $ ((fwin, Rectangle (x + wp) (y + hp) (w - fromIntegral (wp * 2)) (h - fromIntegral (hp * 2))) : rest, Nothing) + ((fwin, _):_) -> return ((fwin, Rectangle (x + wp) (y + hp) (w - fromIntegral (wp * 2)) (h - fromIntegral (hp * 2))) : rest, Nothing) else return (returned, Nothing) where - wp = floor $ (fromIntegral w) * ws - hp = floor $ (fromIntegral h) * hs + wp = floor $ fromIntegral w * ws + hp = floor $ fromIntegral h * hs handleMessOrMaybeModifyIt self@(Zoomable showing sw sh) mess = return $ (handleResize <$> fromMessage mess) - <|> ((Left . handleZoom) <$> fromMessage mess) + <|> (Left . handleZoom <$> fromMessage mess) where handleResize r = if showing diff --git a/src/Main.hs b/src/Main.hs index 0d49e21..741e6dc 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -26,7 +26,7 @@ main = do { terminal = "alacritty" , modMask = mod3Mask , borderWidth = 2 - , keys = \config -> mempty + , keys = const mempty , focusedBorderColor = "#ff6c00" , normalBorderColor = "#404040" , layoutHook = myLayout diff --git a/stack.yaml b/stack.yaml index 81e3e0b..e592062 100644 --- a/stack.yaml +++ b/stack.yaml @@ -17,7 +17,7 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-18.13 +resolver: lts-18.15 # User packages to be built. # Various formats can be used as shown in the example below. -- cgit