I need a bash script or an application to run every time I log in to my computer, regardless of whether it is
* after a reboot
* after a suspend
* after a log out
* after a screen lock
* etc
Basically, every time I enter my password (successfully) I want this script (or application) to run. Is that possible and how?
[Edit] Alternatively, if anyone knows how to check if the computer is locked or unlocked, that would be useful too.
[SOLVED] Perform action when computer is unlocked...
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
[SOLVED] Perform action when computer is unlocked...
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Perform action when computer is unlocked...
What does this script do? is it a per-user kind of thing, or is it sufficient for root to run it?
Re: Perform action when computer is unlocked...
I didn't want to be too morbid so I left it out, but my mom died a week ago, and she was found about three days later, on friday. So, I started to think about what if something happened to me, well, I live alone and 5 hours away from my family, so I probably wouldn't be found until weeks, or months later, especially now when mom is dead. So, I need this to develop a solution that will send an email to my brothers to check up on me, if I have not logged in to my computer (or phone, but I will deal with that later) in 24 or 48 hours or so. Because, if I have not logged into my computer in 48 hours I am definitely deadWhat does this script do?
My thinking is that I this script will open a webpage, that will update a date stored on a server. I could then use that same link from my phone, whenever I have time to fix that. And then I could write a program that checked this date every few hours, to detect when there was last activity, and then send an email if needed.
Definitely only my user account is of interest here...but I guess if it can be handled by the root account, I can live with that...is it a per-user kind of thing, or is it sufficient for root to run it?
Basically, I just need to detect activity on my computer, that is definitely 100% made by a user and not a background process or something...
Re: Perform action when computer is unlocked...
I would personally skip the "automated" approach (sans "@reboot"), as it may get problematic (misfire, not fire, etc). Actually I would skip it on a personal machine in general -- what happens if your ISP goes down when something goes wrong, right?
Slightly more error tolerant (but it does cost money; and is a bit off-the-cuff):
1. get one of those $5 per month VPS's
2. set up a script that fires at login to (re-)set a scheduled job
3. If it's been 48 hours, since the scheduler's been reset, fire the panic notification (sms, email, whatever).
This assumes, of course, that the SMS / Email / etc. isn't going to be missed / rejected as spam (especially given the recent trends to nuke spam calls/texts/etc.). It may actually be more resilient to simply call/text every few days.
Slightly more error tolerant (but it does cost money; and is a bit off-the-cuff):
1. get one of those $5 per month VPS's
2. set up a script that fires at login to (re-)set a scheduled job
3. If it's been 48 hours, since the scheduler's been reset, fire the panic notification (sms, email, whatever).
This assumes, of course, that the SMS / Email / etc. isn't going to be missed / rejected as spam (especially given the recent trends to nuke spam calls/texts/etc.). It may actually be more resilient to simply call/text every few days.
Re: Perform action when computer is unlocked...
So how do I do step 2 you mentioned? I want to at least experiment a little with the concept and see if I kind find a way that works for me.
Re: Perform action when computer is unlocked...
A script at login would be set up in your ~/.bash_profile (or ~/.bashrc) files.