GTK and INotify do not work together

Using GHC, on Ubuntu 13.10, iNotify works -

import Control.Concurrent
import System.INotify

main = do
    n <- initINotify
    addWatch n [Modify] "/home/fred/" $ \event -> do
        putStrLn $ "file changed: " ++ show event
    threadDelay 10000000

and GTK2HS -

import Graphics.UI.Gtk

main = do
    initGUI
    {-Add your widgets here....  or don't, the bug appears either way.-}
    mainGUI

But if I put them together, inotify never starts. (it compiles and works, though ....)

main = do
    n <- initINotify
    addWatch n [Modify] "/home/fred/" $ \event -> do
        putStrLn $ "file changed: " ++ show event
    initGUI
    mainGUI

I tried putting the inotify and GTK stuff in separate streams, it didn't make any difference. I suspect something like signal collisions between libs ....

Oh, and in case that matters, I'm trying to create a small tool that runs in the background, monitors file changes and displays some information in the application progress bar when this happens.


Note -

To start iNotify, simply create or modify the file in the directory specified in addWatch ....

echo "abcd" > /home/fred/aFile

touchdoesn't seem to work.

+4
source share
1 answer

(, , ) -threaded. , inotify main , mainGUI C-land GHC. gtk .

+4

Source: https://habr.com/ru/post/1527581/


All Articles