Get user switch notification in Ubuntu and Kubuntu

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite












I'm writing a daemon in C++ that needs to know when a User Switch event occurs on the desktop(not in a particular terminal). I would like to know if there is an API I can call or a file I can monitor to do this. The daemon needs to run on both Ubuntu and Kubuntu.



Ideally, I would like to be able to do this without polling but if that is the only possible way, I'm ok with that.



I've tried googling but did not find anything relevant. Any help is highly appreciated.










share|improve this question























  • I once did something similar from the shell to find out when the screensaver gets activated. Unfortunately I cannot find my scriptlet any more, nor do I recall the exact commands. But it had to do with the dbus-monitor command. It's a bit similar to inotifywait. Perhaps google for that. I'm pretty sure there's a C/C++ library as well. Try dbus-monitor --system --monitor "type='signal'" in a shell and see what messages appear to get an idea.
    – PerlDuck
    Mar 18 at 13:29











  • See also 0pointer.net/blog/the-new-sd-bus-api-of-systemd.html
    – PerlDuck
    Mar 18 at 13:35










  • @PerlDuck Thanks! I'll check it out.
    – Koderkid
    Mar 18 at 18:28










  • @PerlDuck Thanks to your suggestion I was able to use the dbus to get the user details. If you can post your comment as an answer I can accept it since I do not have the reputation to upvote your comment.
    – Koderkid
    Jun 19 at 9:00














up vote
0
down vote

favorite












I'm writing a daemon in C++ that needs to know when a User Switch event occurs on the desktop(not in a particular terminal). I would like to know if there is an API I can call or a file I can monitor to do this. The daemon needs to run on both Ubuntu and Kubuntu.



Ideally, I would like to be able to do this without polling but if that is the only possible way, I'm ok with that.



I've tried googling but did not find anything relevant. Any help is highly appreciated.










share|improve this question























  • I once did something similar from the shell to find out when the screensaver gets activated. Unfortunately I cannot find my scriptlet any more, nor do I recall the exact commands. But it had to do with the dbus-monitor command. It's a bit similar to inotifywait. Perhaps google for that. I'm pretty sure there's a C/C++ library as well. Try dbus-monitor --system --monitor "type='signal'" in a shell and see what messages appear to get an idea.
    – PerlDuck
    Mar 18 at 13:29











  • See also 0pointer.net/blog/the-new-sd-bus-api-of-systemd.html
    – PerlDuck
    Mar 18 at 13:35










  • @PerlDuck Thanks! I'll check it out.
    – Koderkid
    Mar 18 at 18:28










  • @PerlDuck Thanks to your suggestion I was able to use the dbus to get the user details. If you can post your comment as an answer I can accept it since I do not have the reputation to upvote your comment.
    – Koderkid
    Jun 19 at 9:00












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm writing a daemon in C++ that needs to know when a User Switch event occurs on the desktop(not in a particular terminal). I would like to know if there is an API I can call or a file I can monitor to do this. The daemon needs to run on both Ubuntu and Kubuntu.



Ideally, I would like to be able to do this without polling but if that is the only possible way, I'm ok with that.



I've tried googling but did not find anything relevant. Any help is highly appreciated.










share|improve this question















I'm writing a daemon in C++ that needs to know when a User Switch event occurs on the desktop(not in a particular terminal). I would like to know if there is an API I can call or a file I can monitor to do this. The daemon needs to run on both Ubuntu and Kubuntu.



Ideally, I would like to be able to do this without polling but if that is the only possible way, I'm ok with that.



I've tried googling but did not find anything relevant. Any help is highly appreciated.







16.04 kubuntu services c++ user-management






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 18 at 13:08

























asked Mar 18 at 5:48









Koderkid

12




12











  • I once did something similar from the shell to find out when the screensaver gets activated. Unfortunately I cannot find my scriptlet any more, nor do I recall the exact commands. But it had to do with the dbus-monitor command. It's a bit similar to inotifywait. Perhaps google for that. I'm pretty sure there's a C/C++ library as well. Try dbus-monitor --system --monitor "type='signal'" in a shell and see what messages appear to get an idea.
    – PerlDuck
    Mar 18 at 13:29











  • See also 0pointer.net/blog/the-new-sd-bus-api-of-systemd.html
    – PerlDuck
    Mar 18 at 13:35










  • @PerlDuck Thanks! I'll check it out.
    – Koderkid
    Mar 18 at 18:28










  • @PerlDuck Thanks to your suggestion I was able to use the dbus to get the user details. If you can post your comment as an answer I can accept it since I do not have the reputation to upvote your comment.
    – Koderkid
    Jun 19 at 9:00
















  • I once did something similar from the shell to find out when the screensaver gets activated. Unfortunately I cannot find my scriptlet any more, nor do I recall the exact commands. But it had to do with the dbus-monitor command. It's a bit similar to inotifywait. Perhaps google for that. I'm pretty sure there's a C/C++ library as well. Try dbus-monitor --system --monitor "type='signal'" in a shell and see what messages appear to get an idea.
    – PerlDuck
    Mar 18 at 13:29











  • See also 0pointer.net/blog/the-new-sd-bus-api-of-systemd.html
    – PerlDuck
    Mar 18 at 13:35










  • @PerlDuck Thanks! I'll check it out.
    – Koderkid
    Mar 18 at 18:28










  • @PerlDuck Thanks to your suggestion I was able to use the dbus to get the user details. If you can post your comment as an answer I can accept it since I do not have the reputation to upvote your comment.
    – Koderkid
    Jun 19 at 9:00















I once did something similar from the shell to find out when the screensaver gets activated. Unfortunately I cannot find my scriptlet any more, nor do I recall the exact commands. But it had to do with the dbus-monitor command. It's a bit similar to inotifywait. Perhaps google for that. I'm pretty sure there's a C/C++ library as well. Try dbus-monitor --system --monitor "type='signal'" in a shell and see what messages appear to get an idea.
– PerlDuck
Mar 18 at 13:29





I once did something similar from the shell to find out when the screensaver gets activated. Unfortunately I cannot find my scriptlet any more, nor do I recall the exact commands. But it had to do with the dbus-monitor command. It's a bit similar to inotifywait. Perhaps google for that. I'm pretty sure there's a C/C++ library as well. Try dbus-monitor --system --monitor "type='signal'" in a shell and see what messages appear to get an idea.
– PerlDuck
Mar 18 at 13:29













See also 0pointer.net/blog/the-new-sd-bus-api-of-systemd.html
– PerlDuck
Mar 18 at 13:35




See also 0pointer.net/blog/the-new-sd-bus-api-of-systemd.html
– PerlDuck
Mar 18 at 13:35












@PerlDuck Thanks! I'll check it out.
– Koderkid
Mar 18 at 18:28




@PerlDuck Thanks! I'll check it out.
– Koderkid
Mar 18 at 18:28












@PerlDuck Thanks to your suggestion I was able to use the dbus to get the user details. If you can post your comment as an answer I can accept it since I do not have the reputation to upvote your comment.
– Koderkid
Jun 19 at 9:00




@PerlDuck Thanks to your suggestion I was able to use the dbus to get the user details. If you can post your comment as an answer I can accept it since I do not have the reputation to upvote your comment.
– Koderkid
Jun 19 at 9:00















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1016918%2fget-user-switch-notification-in-ubuntu-and-kubuntu%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1016918%2fget-user-switch-notification-in-ubuntu-and-kubuntu%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

GRUB: Fatal! inconsistent data read from (0x84) 0+xxxxxx

What makes Checkinstall packages not suitable for distribution?

Running the scala interactive shell from the command line