packages feed

greenclip 3.2.0 → 3.3.0

raw patch · 3 files changed

+58/−23 lines, 3 files

Files

README.md view
@@ -5,7 +5,7 @@ ## Description  Recyle your clipboard selections with greenclip and don't waste your time anymore-to reselect things other and other.+to reselect things over and over.  **Purpose:** Keeps track of your history of selections to quickly switch between them@@ -25,11 +25,11 @@  1. It's a static binary so drop it anywhere in your $PATH env -```wget https://github.com/erebe/greenclip/releases/download/3.0/greenclip```+```wget https://github.com/erebe/greenclip/releases/download/3.2/greenclip```  Alternatively if you are using Archlinux you can install the package from AUR -``pacman -S rofi-greenclip``+``yay rofi-greenclip``  PS: If you want, you can add a permanent list of selections to be added to your current history. Go see the config file @@ -58,34 +58,63 @@  ## FAQ -Q. Greenclip does not copy selection !+Q. **Greenclip does not copy selection !**  A. Greenclip cannot run alongside other clipboard manager. If you have already one activated (there is one by default in KDE), you have first to disable it before trying to run greenclip  --------- -Q. I cannot paste images !+Q. **I cannot paste images !**  A. You can only keep in your history small images  (~ <500 kb). I disabled the support for bigger images as it will turn your CPU into a heater for winter.  ---------- -Q. I want to blacklist some applications !+Q. **I want to blacklist some applications !**  A. There is in your config file a section for blacklisting applications.    You can run greenclip daemon in a terminal to find what is the name of the application who has the current selection.    Be aware that a lot of application does not name their clipboard process/window, so it will be empty most of the time.    Be aware also, that if you use an electron application (like slack i.e) you will get a generic name like "Chromium clipboard"-   + ---------- -Q. I want to paste selection directly after selecting them !+Q. **I want to paste selection directly after selecting them !**  A. This is not possible as when you invoke rofi, you lose focus of your current window and there is no way to find it back (from greenclip point of view)-   Nonetheless, you can emulate the feature with xdotool `rofi -modi "clipboard:greenclip print" -show clipboard -run-command '{cmd}' ; sleep 0.5; xdotool type (xclip -o -selection clipboard)` +   Nonetheless, you can emulate the feature with xdotool `rofi -modi "clipboard:greenclip print" -show clipboard -run-command '{cmd}' ; sleep 0.5; xdotool type $(xclip -o -selection clipboard)`++   or look at this issue for a more complete solution https://github.com/erebe/greenclip/issues/27+ ---------- -Q. I want to thank you for greenclip !+Q. **I got a strange behavior when clearing the clipboard - greenclip clear**++A. The command is not doing what it is supposed to do, if greenclip's daemon is running. You need to stop it first.++   Use this command to clear the history `pkill greenclip && greenclip clear && greenclip daemon &`+   +   For more information regarding why, refer to https://github.com/erebe/greenclip/issues/34 ++----------++Q. **I need multi-line text in staticHistory**++A. https://github.com/erebe/greenclip/issues/78++----------++Q. **I don't want to use rofi !**++A. You can also use greenclip with [dmenu](http://tools.suckless.org/dmenu) or [fzf](https://github.com/junegunn/fzf). Example usage:++   `greenclip print | sed '/^$/d' | dmenu -i -l 10 -p clipboard | xargs -r -d'\n' -I '{}' greenclip print '{}'`++   `greenclip print | sed '/^$/d' | fzf -e | xargs -r -d'\n' -I '{}' greenclip print '{}'`++----------++Q. **I want to thank you for greenclip !**  A. Give a star to this repository
greenclip.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:           greenclip-version:        3.2.0+version:        3.3.0 synopsis:       Simple clipboard manager to be integrated with rofi description:    Simple clipboard manager to be integrated with rofi - Please see README.md category:       Linux Desktop
src/Main.hs view
@@ -12,9 +12,10 @@ import           Protolude             hiding (readFile, to, (<&>), (&))  import           Control.Monad.Catch   (MonadCatch, catchAll)-import           Data.Binary           (decode, encode)+import           Data.Binary           (decodeFile, encode) import qualified Data.ByteString       as B import           Data.Hashable         (hash)+import           Data.List             (dropWhileEnd) import qualified Data.Text             as T import           Data.Vector           (Vector) import qualified Data.Vector           as V@@ -54,9 +55,7 @@ getHistory :: (MonadIO m, MonadReader Config m) => m ClipHistory getHistory = do   storePath <- view $ to (toS . historyPath)-  liftIO $ readH storePath `catchAll` const mempty-  where-    readH filePath = B.readFile filePath <&> V.fromList . decode . toS+  liftIO $ (V.fromList <$> decodeFile storePath) `catchAll` const mempty   getStaticHistory :: (MonadIO m, MonadReader Config m) => m ClipHistory@@ -90,7 +89,7 @@     appendImage imgCtr extension bytes = do       cachePth <- view (to imageCachePath)       let imgHash = show $ hash bytes-      let imgPath = toS $ cachePth <> imgHash <> extension+      let imgPath = toS $ cachePth <> "/" <> imgHash <> extension       _ <- liftIO $ writeImage imgPath bytes       appendGeneric (sel {Clip.selection = imgCtr $ toS imgHash}) history' @@ -98,7 +97,7 @@       fileExist <- Dir.doesFileExist path       if fileExist         then return False-        else B.writeFile path bytes >> return True+        else B.writeFile path bytes >> setFileMode path 0o600 >> return True      appendGeneric selection history =       if maybe False (\sel' -> Clip.selection sel' == Clip.selection selection) (history V.!? 0)@@ -115,8 +114,15 @@   when (not fileExist) (storeHistory mempty)   liftIO $ setFileMode storePath 0o600 +prepareDirs :: (MonadIO m, MonadReader Config m) => m ()+prepareDirs = do+  historyFile <- view $ to (T.unpack . historyPath)+  imgDir <- view $ to (T.unpack . imageCachePath)+  let dirs = [imgDir, dropWhileEnd (/= '/') historyFile]+  mapM_ (liftIO . Dir.createDirectoryIfMissing True) dirs+ runDaemon:: (MonadIO m, MonadCatch m, MonadReader Config m) => m ()-runDaemon = setHistoryFilePermission >> (forever $ go `catchAll` handleError)+runDaemon = prepareDirs >> setHistoryFilePermission >> (forever $ go `catchAll` handleError)   where     _0_5sec :: Int     _0_5sec = 5 * 100000@@ -191,9 +197,9 @@ toRofiStr (Clip.Selection appName (Clip.BITMAP txt)) = "image/bmp " <> appName <> " " <> toS txt  fromRofiStr :: Text -> Text -> IO Clip.Selection-fromRofiStr cachePth txt@(T.isPrefixOf "image/png " -> True) = B.readFile (toS $ cachePth <> getHash txt <> ".png") <&> Clip.Selection "greenclip" . Clip.PNG-fromRofiStr cachePth txt@(T.isPrefixOf "image/jpeg " -> True) = B.readFile (toS $ cachePth <> getHash txt <> ".jpeg") <&> Clip.Selection "greenclip" . Clip.JPEG-fromRofiStr cachePth txt@(T.isPrefixOf "image/bmp " -> True) = B.readFile (toS $ cachePth <> getHash txt <> ".bmp") <&> Clip.Selection "greenclip" . Clip.BITMAP+fromRofiStr cachePth txt@(T.isPrefixOf "image/png " -> True) = B.readFile (toS $ cachePth <> "/" <> getHash txt <> ".png") <&> Clip.Selection "greenclip" . Clip.PNG+fromRofiStr cachePth txt@(T.isPrefixOf "image/jpeg " -> True) = B.readFile (toS $ cachePth <> "/" <> getHash txt <> ".jpeg") <&> Clip.Selection "greenclip" . Clip.JPEG+fromRofiStr cachePth txt@(T.isPrefixOf "image/bmp " -> True) = B.readFile (toS $ cachePth <> "/" <> getHash txt <> ".bmp") <&> Clip.Selection "greenclip" . Clip.BITMAP fromRofiStr _ txt = return $ Clip.Selection "greenclip" (Clip.UTF8 (T.map (\c -> if c == '\xA0' then '\n' else c) txt))  getHash :: Text -> Text@@ -244,7 +250,7 @@                }    where-    defaultConfig = Config 50 "~/.cache/greenclip.history" "~/.cache/greenclip.staticHistory" "/tmp/" False [] True+    defaultConfig = Config 50 "~/.cache/greenclip.history" "~/.cache/greenclip.staticHistory" "/tmp/greenclip/" False [] True     expandHomeDir str = (toS . fromMaybe (toS str) . listToMaybe <$> wordexp (toS str)) `catchAll` (\_ -> return $ toS str)  @@ -265,7 +271,7 @@     -- Should rename COPY into ADVERTISE but as greenclip is already used I don't want to break configs     -- of other people     COPY sel -> runReaderT (advertiseSelection sel) cfg-    HELP     -> putText $ "greenclip v3.2 -- Recyle your clipboard selections\n\n" <>+    HELP     -> putText $ "greenclip v3.3 -- Recyle your clipboard selections\n\n" <>                           "Available commands\n" <>                           "daemon: Spawn the daemon that will listen to selections\n" <>                           "print:  Display all selections history\n" <>