easyconf-lemonbar/easyconf_lemonbar/pidfile.py

15 lines
344 B
Python
Raw Permalink Normal View History

2023-04-02 19:37:33 +00:00
from os import chmod, getpid, getuid, remove
def pidfile_name():
filepath = "/run/user/" + str(getuid()) + "/easyconf-lemonbar.pid"
return filepath
def create_pidfile(filepath):
with open(filepath, "w") as file:
file.write(str(getpid()))
chmod(filepath, 0o644)
def delete_pidfile(filepath):
remove(filepath)