Skip to content

Instantly share code, notes, and snippets.

@d8660091
Created October 24, 2016 01:32
Show Gist options
  • Save d8660091/2f058234041de1595ffae4a4e94edec0 to your computer and use it in GitHub Desktop.
Save d8660091/2f058234041de1595ffae4a4e94edec0 to your computer and use it in GitHub Desktop.
input method indicator
{-# LANGUAGE OverloadedStrings #-}
import DBus
import DBus.Client
import Control.Monad (forever)
import Control.Concurrent (threadDelay)
import System.IO
fakeSignal :: Signal
fakeSignal = undefined
callBack :: Client -> Signal -> IO ()
callBack client _ = do
reply <- call_ client (methodCall "/inputmethod" "org.fcitx.Fcitx.InputMethod" "GetCurrentIM") {
methodCallDestination = Just "org.fcitx.Fcitx"
}
let Just current_im = fromVariant $ methodReturnBody reply !! 0 :: Maybe String
putStrLn current_im
hFlush stdout
matchFromFcitx :: MatchRule
matchFromFcitx = matchAny { matchPath = Just "/inputmethod" }
main = do
client <- connectSession
callBack client fakeSignal
addMatch client matchFromFcitx (callBack client)
forever $ threadDelay 10000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment