I have a script to toggle my screen backlight (mapped to a keyboard shortcut), and I want to save the brightness level so I can restore it when pressing the keyboard shortcut again.
Is there a standard place to save such files? Or should I just create some folder in my home directory to save them there?
I don't want to save them to /tmp
because:
Programs must not assume that any files or directories in /tmp are preserved between invocations of the program.
Best Answer
On Linux,
/run
or/var/run
are the standard places for things that are not required to survive a reboot, but mustn't be removed by e.g.tmpreaper
. Daemons generally keep their pid files in there, for instance.If your script runs as an ordinary user, then a dot-directory in that user's home directory is probably the right choice. That's where applications with persistent settings (e.g. Firefox, GIMP, etc) keep their data.