Location for system & luser scripts

jbo@

Developer
I am running FreeBSD 12.1 on a Lenovo Thinkpad X1 Carbon successfully.

I created a devd rule that executes a script when the lid switch is toggled so I can lock my screen and suspend the system (enter S3). The script executed by devd does two thingss:
  1. Lock screen - This is done by running a separate script.
  2. Enter suspend mode
The script that locks the screen is located in the user's directory (eg. `$HOME/scripts/lock_screen.sh). But the main script called by devd is located under /etc/acpi/lid.conf as this is a system file. That file in turn runs /usr/home/my_user/scripts/lock_screen.sh. Therefore, the system file has a hardcoded path to a user's custom lock script (as $HOME doesn't point to the "proper" user).

This is obviously far from good and I'd like to learn what the best way of handling this is.
Should the locking script also be part of the system itself and not of the user? My reasoning was that the graphical user interface is ran by the user using the system - not by the system itself (or root).

So far I have only used FreeBSD on servers & infrastructure and I never came across a situation like this - time to learn! :)
 
This is obviously far from good and I'd like to learn what the best way of handling this is.
Should the locking script also be part of the system itself and not of the user? My reasoning was that the graphical user interface is ran by the user using the system - not by the system itself (or root).
I would argue it belongs to the system and not the user, since every user will execute the same script. I.e., there aren't different ways of handling lid closure depending on the user.

So far I have only used FreeBSD on servers & infrastructure and I never came across a situation like this - time to learn! :)
Merely my opinion. No idea if this is the correct way to think about it.
 
If you want to reserve /usr/local for ports & / for base, you could choose /opt/etc/acpi & /opt/libexec for such scripts. Perl & other software used to have a site directory, you can also chose that name instead (/usr/site/{etc/acpi,libexec} or just plain /site/{etc/acpi,libexec})
 
I would argue it belongs to the system and not the user, since every user will execute the same script. I.e., there aren't different ways of handling lid closure depending on the user.
Well, I assumed that I can have multiple desktop environments installed and one user might like to use i3 with i3lock while another user might prefer xfce with xfce-screenlocker.

If it is not incorrect from a technical point of view I will indeed migrate everything to /opt/etc.

Thank you for sharing your wisdom!
 
I guess you could set a SCREENLOCK_PROGRAM environment variable in each user's profile with the path to the correct program. System script only suspends if this variable is not set.
 
Back
Top