Created
October 24, 2016 01:32
-
-
Save d8660091/2f058234041de1595ffae4a4e94edec0 to your computer and use it in GitHub Desktop.
input method indicator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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