ENH change screenshot directory to xdg_data

ADD browse screen captures
This commit is contained in:
Nathan Dwarshuis 2020-05-03 00:04:35 -04:00
parent 4daada9020
commit 7b52b34edb
3 changed files with 28 additions and 6 deletions

View File

@ -396,6 +396,7 @@ mkKeys ts c =
, ("M-C-s", "capture area", runAreaCapture)
, ("M-C-S-s", "capture screen", runScreenCapture)
, ("M-C-d", "capture desktop", runDesktopCapture)
, ("M-C-b", "browse captures", runCaptureBrowser)
-- , ("M-C-S-s", "capture focused window", spawn myWindowCap)
] ++

View File

@ -26,11 +26,17 @@ module XMonad.Internal.Command.Desktop
, runAreaCapture
, runScreenCapture
, runDesktopCapture
, runCaptureBrowser
) where
import Control.Monad (void)
import System.Directory (getHomeDirectory)
import System.Directory
( createDirectoryIfMissing
, getHomeDirectory
)
import System.Environment
import System.FilePath
import XMonad.Actions.Volume
import XMonad.Core hiding (spawn)
@ -140,14 +146,23 @@ runRecompile = do
--------------------------------------------------------------------------------
-- | Screen capture commands
getScreenshotDir :: IO FilePath
getScreenshotDir = do
h <- getHomeDirectory
return $ h ++ "/Pictures/screenshots"
getCaptureDir :: IO FilePath
getCaptureDir = do
e <- lookupEnv "XDG_DATA_HOME"
parent <- case e of
Nothing -> fallback
Just path
| isRelative path -> fallback
| otherwise -> return path
let fullpath = parent </> "screenshots"
createDirectoryIfMissing True fullpath
return fullpath
where
fallback = (</> ".local/share") <$> getHomeDirectory
runFlameshot :: String -> X ()
runFlameshot mode = do
ssDir <- io getScreenshotDir
ssDir <- io getCaptureDir
spawnCmd "flameshot" $ mode : ["-p", ssDir]
-- TODO this will steal focus from the current window (and puts it
@ -162,3 +177,8 @@ runScreenCapture = runFlameshot "screen"
runDesktopCapture :: X ()
runDesktopCapture = runFlameshot "full"
runCaptureBrowser :: X ()
runCaptureBrowser = do
dir <- io getCaptureDir
spawnCmd "geeqie" [dir]

View File

@ -37,6 +37,7 @@ library
, text >= 1.2.3.1
, directory >= 1.3.3.0
, process >= 1.6.5.0
, filepath >= 1.4.2.1
, xmobar
, xmonad-extras >= 0.15.2
, xmonad >= 0.13