summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Minar <mic.liamg@gmail.com>2015-08-29 14:36:39 +0200
committerMichal Minar <mic.liamg@gmail.com>2015-08-29 14:36:39 +0200
commit5aa4dbc8777612dc2223a00e85acf62b886a40b8 (patch)
treebf023168635c8c5fe20311131ad536487f99bce0
parent4039213b0fa187c614801eb21d8578d902ea267e (diff)
downloadxminad-5aa4dbc8777612dc2223a00e85acf62b886a40b8.tar.gz
xminad-5aa4dbc8777612dc2223a00e85acf62b886a40b8.tar.xz
xminad-5aa4dbc8777612dc2223a00e85acf62b886a40b8.zip
Added keybindings for mpd control
Signed-off-by: Michal Minar <mic.liamg@gmail.com>
-rw-r--r--src/XMonad/Local/Keys.hs20
-rw-r--r--src/XMonad/Local/Music.hs15
-rw-r--r--xminad.cabal1
3 files changed, 33 insertions, 3 deletions
diff --git a/src/XMonad/Local/Keys.hs b/src/XMonad/Local/Keys.hs
index 1f63fcb..7f719fa 100644
--- a/src/XMonad/Local/Keys.hs
+++ b/src/XMonad/Local/Keys.hs
@@ -39,6 +39,7 @@ import XMonad.Util.WorkspaceCompare (getSortByIndex)
import qualified XMonad.Local.Actions as Local
import XMonad.Local.Config
import qualified XMonad.Local.GridSelect as Local
+import qualified XMonad.Local.Music as Local
import XMonad.Local.NamedScratchpad
import XMonad.Local.TopicSpace
import qualified XMonad.Local.Workspaces as Local
@@ -57,7 +58,7 @@ emacsKeys = \conf -> map prefix (keysMissingPrefix conf) ++ unprefixedKeys
prefix :: (String, a) -> (String, a)
prefix (k, a) = (modm ++ "-" ++ k, a)
- keysMissingPrefix conf = concat $
+ keysMissingPrefix conf = concat
[ genericKeys conf
, switchWorkspaceKeys
, switchScreenKeys
@@ -139,7 +140,7 @@ genericKeys conf = [
, ("[", moveTo Prev $ WSIs nonEmptyWsPred)
, ("-", SUB.submap $ EZ.mkKeymap conf
[ (m ++ show k, withNthWorkspace f i)
- | (k, i) <- (zip ([1..9] ++ [0]) [10..] :: [(Int, Int)])
+ | (k, i) <- zip ([1..9] ++ [0]) [10..] :: [(Int, Int)]
, (f, m) <- concat
[ [ -- switch to ith workspace
(W.greedyView, m)
@@ -191,7 +192,20 @@ genericKeys conf = [
-- misc
, ("S-h", PSsh.sshPrompt xpConfig)
--, ("<Print>", spawn "xfce4-screenshooter")
- , ("y", spawn "xfce4-popup-clipman")
+ , ("y", SUB.submap $ EZ.mkKeymap conf $ concat
+ [ [(k, a), (modm ++ "-" ++ k, a)]
+ | (k, a) <- [ ("n", io $ return . fromRight =<< MPD.withMPD MPD.next)
+ , ("p", io $ return . fromRight =<< MPD.withMPD MPD.previous)
+ , ("S-.", io $ return . fromRight =<< MPD.withMPD MPD.next)
+ , ("S-,", io $ return . fromRight =<< MPD.withMPD MPD.previous)
+ , ("y", io $ return . fromRight =<< MPD.withMPD (MPD.play Nothing))
+ , ("s", io $ return . fromRight =<< MPD.withMPD MPD.stop)
+ , ("r", io $ return . fromRight =<< MPD.withMPD Local.toggleRepeat)
+ , ("*", io $ return . fromRight =<< MPD.withMPD Local.toggleRandom)
+ , ("S-8", io $ return . fromRight =<< MPD.withMPD Local.toggleRandom)
+ , ("<Space>", io $ return . fromRight =<< MPD.withMPD MPD.toggle)
+ ]
+ ])
, ("<Print>", spawn "mate-screenshot")
, ("C-<Print>", spawn "mate-screenshot -w")
, ("S-<Print>", spawn "mate-screenshot -a")
diff --git a/src/XMonad/Local/Music.hs b/src/XMonad/Local/Music.hs
new file mode 100644
index 0000000..d55fbbc
--- /dev/null
+++ b/src/XMonad/Local/Music.hs
@@ -0,0 +1,15 @@
+module XMonad.Local.Music where
+
+import Control.Monad (liftM)
+
+import qualified Network.MPD as MPD
+
+toggleRepeat :: MPD.MonadMPD m => m()
+toggleRepeat = do
+ repeatState <- liftM MPD.stRepeat MPD.status
+ MPD.repeat $ not repeatState
+
+toggleRandom :: MPD.MonadMPD m => m()
+toggleRandom = do
+ randomState <- liftM MPD.stRandom MPD.status
+ MPD.random $ not randomState
diff --git a/xminad.cabal b/xminad.cabal
index 6cb8921..2ef2783 100644
--- a/xminad.cabal
+++ b/xminad.cabal
@@ -58,6 +58,7 @@ Library
XMonad.Local.Layout
XMonad.Local.ManageHook
XMonad.Local.Mouse
+ XMonad.Local.Music
XMonad.Local.NamedScratchpad
XMonad.Local.TopicSpace
XMonad.Local.Workspaces