Skip to content

Commit

Permalink
Fix for PopOS os_release problem (#311)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

Co-authored-by: bobslept <[email protected]>
  • Loading branch information
emilyastranova and bobslept authored Dec 19, 2021
1 parent 00eca65 commit 7236e67
Showing 1 changed file with 24 additions and 2 deletions.
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":
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)

0 comments on commit 7236e67

Please sign in to comment.