[xmonad] prompt for clipboard history

adam vogt vogt.adam at gmail.com
Sat Jul 20 14:59:19 CEST 2013


On Fri, Jul 19, 2013 at 1:57 PM, Donatella Quagli
<donatella.quagli at yahoo.de> wrote:
> 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 ()




More information about the xmonad mailing list