Get user switch notification in Ubuntu and Kubuntu

Clash 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.
16.04 kubuntu services c++ user-management
add a comment |Â
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.
16.04 kubuntu services c++ user-management
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 thedbus-monitorcommand. It's a bit similar to inotifywait. Perhaps google for that. I'm pretty sure there's a C/C++ library as well. Trydbus-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
add a comment |Â
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.
16.04 kubuntu services c++ user-management
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
16.04 kubuntu services c++ user-management
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 thedbus-monitorcommand. It's a bit similar to inotifywait. Perhaps google for that. I'm pretty sure there's a C/C++ library as well. Trydbus-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
add a comment |Â
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 thedbus-monitorcommand. It's a bit similar to inotifywait. Perhaps google for that. I'm pretty sure there's a C/C++ library as well. Trydbus-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
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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-monitorcommand. It's a bit similar to inotifywait. Perhaps google for that. I'm pretty sure there's a C/C++ library as well. Trydbus-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