简体   繁体   中英

Linux Lock/Unlock events handling

Currently I'm trying to record system lock/unlock events on linux, under mono c#. I was hoping to achieve this with the help of dbus , using different components on different desktop environments. And I was able to do so on Ubuntu with Unity, using Ndesk.DBus api, but it seems that there's no such signals on Xfce desktop. I've checked dbus-monitor "type=signal" there and it shows completely nothing useful on lock/unlock. So, is there any cross-desktop way to record system events (I also need login/logout and active window change)?

The answer is a bit complicated, but theoretically, there is a cross-desktop way to handle user session events, it's an org.freedesktop.login1 object from logind daemon. It sends all needed signals by system bus, at least it should according to documentation. But in reality it doesn't. On different desktops some different signals are not sent. Most missing signals may be caught from other objects, for example lock|unlock signals are sent by various ScreenSaver daemons. By the way, on Xfce logind sends such signals, instead of sreensaver.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM