ENH add a tmux command

This commit is contained in:
Nathan Dwarshuis 2021-06-17 01:17:59 -04:00
parent 54f0903214
commit 359312ff50
4 changed files with 23 additions and 6 deletions

View File

@ -1,6 +1,5 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf #-}
--------------------------------------------------------------------------------
-- | XMonad binary
@ -446,7 +445,8 @@ mkKeys ts c =
, ("M-b", "launch bitwarden selector", runBwMenu)
, ("M-C-e", "launch editor", runEditor)
, ("M-C-w", "launch browser", runBrowser)
, ("M-C-t", "launch terminal", runTerm)
, ("M-C-t", "launch terminal with tmux", runTMux)
, ("M-C-S-t", "launch terminal", runTerm)
, ("M-C-q", "launch calc", runCalc)
, ("M-C-f", "launch file manager", runFileManager)
] ++

View File

@ -4,6 +4,7 @@
module XMonad.Internal.Command.Desktop
( myTerm
, runTerm
, runTMux
, runCalc
, runBrowser
, runEditor
@ -59,6 +60,15 @@ myTerm = "urxvt"
runTerm :: X ()
runTerm = spawn myTerm
runTMux :: X ()
runTMux = spawn
$ "tmux has-session"
#!&& fmtCmd myTerm ["-e", "bash", "-c", singleQuote c]
#!|| fmtNotifyCmd defNoteError { body = Just $ Text msg }
where
c = "exec tmux attach-session -d"
msg = "could not connect to tmux session"
runCalc :: X ()
runCalc = spawnCmd myTerm ["-e", "R"]
@ -67,7 +77,7 @@ runBrowser = spawn "brave-accel"
runEditor :: X ()
runEditor = spawnCmd "emacsclient"
["-c", "-e", "\"(select-frame-set-input-focus (selected-frame))\""]
["-c", "-e", doubleQuote "(select-frame-set-input-focus (selected-frame))"]
runFileManager :: X ()
runFileManager = spawn "pcmanfm"

View File

@ -49,8 +49,7 @@ fmtNotifyCmd note =
++ getBody note
where
-- TODO add the rest of the options as needed
getSummary = (:[]) . quote . summary
getSummary = (:[]) . doubleQuote . summary
getIcon n = maybe [] (\i -> ["-i", case i of { Icon s -> s; File s -> s }])
$ appImage n
getBody n = maybeToList $ (fmap quote . parseBody) =<< body n
quote s = "\"" ++ s ++ "\""
getBody n = maybeToList $ (fmap doubleQuote . parseBody) =<< body n

View File

@ -5,6 +5,8 @@ module XMonad.Internal.Shell
( fmtCmd
, spawnCmd
, spawnSound
, doubleQuote
, singleQuote
, (#!&&)
, (#!||)
, (#!>>)
@ -55,3 +57,9 @@ infixr 0 #!||
cmdA #!>> cmdB = cmdA ++ "; " ++ cmdB
infixr 0 #!>>
doubleQuote :: String -> String
doubleQuote s = "\"" ++ s ++ "\""
singleQuote :: String -> String
singleQuote s = "'" ++ s ++ "'"