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)