From 7236e674f4ef96da0c2de8da6aeab355b86bc033 Mon Sep 17 00:00:00 2001 From: tyleraharrison Date: Sun, 19 Dec 2021 02:20:09 -0600 Subject: [PATCH] Fix for PopOS os_release problem (#311) * Fix for PopOS os_release problem Fixes issue #276 * Added Pop!_OS detection * Removed redundant abort code in Pop!_OS detection * Added exit case for pressing 'N' or not pressing anything Also fixed weird whitespace issue with backslash * Changed to "Operation aborted by user" for 'N' * Update auto_cpufreq/core.py Co-authored-by: bobslept <38557801+bobslept@users.noreply.github.com> Co-authored-by: bobslept <38557801+bobslept@users.noreply.github.com> --- auto_cpufreq/core.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index 6ab60ae..24bda03 100644 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -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": + 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(): @@ -1085,4 +1107,4 @@ def running_daemon(): exit(1) elif os.getenv("PKG_MARKER") == "SNAP" and dcheck == "enabled": daemon_running_msg() - exit(1) \ No newline at end of file + exit(1)