Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for PopOS os_release problem #311

Merged
merged 8 commits into from
Dec 19, 2021
26 changes: 24 additions & 2 deletions auto_cpufreq/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,29 @@ def get_config(config_file=''):
return get_config.dict

# get distro name
dist_name = distro.id()
try:
dist_name = distro.id()
except PermissionError:
# Current work-around for distros like Pop!_OS where symlink causes permission issues
print("Warning: Cannot get distro name")
if os.path.exists("/etc/pop-os/os-release"):
print("Pop!_OS detected")
print("Pop!_OS uses a symbolic link for the os-release file, this causes issues and can be fixed by converting to a hard link")
print("Attempting to change symlink to hard link for /etc/os-release -> /etc/pop-os/os-release")

yN = input("Continue? [y/N] ")
if yN.lower() == "y":
emilyastranova marked this conversation as resolved.
Show resolved Hide resolved
print("Creating hard link for /etc/os-release")
# Backup /etc/os-release
os.system("sudo mv /etc/os-release /etc/os-release-backup")
# Create hard link to /etc/os-release
os.system("sudo ln /etc/pop-os/os-release /etc/os-release")
else:
print("Operation aborted by user")
sys.exit(1)
else:
print("Aborting...")
sys.exit(1)

# display running version of auto-cpufreq
def app_version():
Expand Down Expand Up @@ -1085,4 +1107,4 @@ def running_daemon():
exit(1)
elif os.getenv("PKG_MARKER") == "SNAP" and dcheck == "enabled":
daemon_running_msg()
exit(1)
exit(1)