prompt for clipboard history

Dear all, I would like to have a prompt command to reselect something from my clipboard history. The history is created with a simple cron job that executes xclip -o >> $HOME/.clipboard-history every second. My question is, how can I create the auto completion list from that file? I tried for many hours and finally gave up. My last try was this command: ((mod3Mask, xK_c), inputPromptWithCompl myXPConfig "clipboard" mkComplFunFromList(runProcessWithInput "cat /home/donatella/.clipboard-history") ?+ (\r -> spawn $ "echo" ++ r ++ "| xclip")) which did not work. Can anybody help me? Thanks in advance Donatella

On Fri, Jul 19, 2013 at 1:57 PM, Donatella Quagli
Dear all,
I would like to have a prompt command to reselect something from my clipboard history. The history is created with a simple cron job that executes xclip -o >> $HOME/.clipboard-history every second.
My question is, how can I create the auto completion list from that file? I tried for many hours and finally gave up. My last try was this command: ((mod3Mask, xK_c), inputPromptWithCompl myXPConfig "clipboard" mkComplFunFromList(runProcessWithInput "cat /home/donatella/.clipboard-history") ?+ (\r -> spawn $ "echo" ++ r ++ "| xclip")) which did not work. Can anybody help me?
Hi Donatella, You're pretty close. The functions you used don't take argument with types IO a, they take just the 'a' produced by running the IO a. Here's a pretty verbose way to do it, which might be easier to understand: clipboardHistoryPrompt = let cmd :: String -> X () cmd r = spawn $ "echo" ++ r ++ "| xclip" complFun :: ComplFunction complFun s = do history <- readFile "/home/donatella/.clipboard-history" mkComplFunFromList (lines history) s in do input <- inputPromptWithCompl myXPConfig "clipboard" complFun case input of Just i -> cmd i _ -> return ()

Hi Adam, thanks for answering so quickly! It does exactly what I wanted. I should add there must be a whitespace between echo and the double quote. Unfortunately I encountered some problems. One drawback is that the history is not shown before the first letter is typed. Another problem is that whitespace characters are not treated correctly. If you or anybody else know how to solve this it would be nice. But I think it is not worth to invest alot of time. I probably could try dmenu instead. By the way I found many broken links on xmonad.org/xmonad-docs. Is there an intact mirror? Regards Donatella

On Sat, Jul 20, 2013 at 2:23 PM, Donatella Quagli wrote: By the way I found many broken links on xmonad.org/xmonad-docs. Is there
an
intact mirror? Not currently but it should be back in a few days. (The web site hosting
xmonad.org and haskell.org is undergoing maintenance.)
--
brandon s allbery kf8nh sine nomine associates
allbery.b@gmail.com ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On Sat, Jul 20, 2013 at 2:59 PM, Brandon Allbery
On Sat, Jul 20, 2013 at 2:23 PM, Donatella Quagli
wrote: By the way I found many broken links on xmonad.org/xmonad-docs. Is there an intact mirror?
Not currently but it should be back in a few days. (The web site hosting xmonad.org and haskell.org is undergoing maintenance.)
I don't think xmonad.org has been involved with any maintenance. Maybe the broken links are links to packages which have not been included on xmonad.org. For example: The page http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-DynamicWorkspace... has a broken link to http://xmonad.org/xmonad-docs/base/Data-String.html#t:String. That should be fixed. In the meantime, you can probably find what you're looking for in one of these places: - http://hackage.haskell.org/package/xmonad-contrib (or elsewhere on hackage) - $HOME/.cabal/share/doc/index.html - /usr/share/doc/ghc/html/index.html -- Adam

Hi Donatella,
See responses inline:
On Sat, Jul 20, 2013 at 2:23 PM, Donatella Quagli
Unfortunately I encountered some problems. One drawback is that the history is not shown before the first letter is typed.
I think if you use mkComplFunFromList' instead of mkComplFunFromList that'll give completions for no text.
Another problem is that whitespace characters are not treated correctly.
Maybe the problem is your use of echo? If you try in your shell, you'll see a difference between these two: echo a b c def echo "a b c def" One way around this might involve System.Process, : cmd r = do io (readProcess "xclip" [] r) return () Or maybe the right thing happens if you just add quotes to the shell command: cmd r = spawn $ "echo '" ++ r ++ "' | xclip" -- Adam

Dear all, thanks for your great support! Regards Donatella
participants (3)
-
adam vogt
-
Brandon Allbery
-
Donatella Quagli