Turning Bluetooth off/on & Void Linux improvements (#269)

This commit is contained in:
Animesh Sahu 2021-11-04 07:32:50 +00:00 committed by GitHub
parent a48e9193fa
commit 4fee7b680b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 27 deletions

View File

@ -130,7 +130,7 @@ elif [ -f /etc/os-release ];then
;; ;;
void) void)
detected_distro "Void Linux" detected_distro "Void Linux"
xbps-install -Suy python3 python3-pip python3-devel python3-setuptools base-devel dmidecode xbps-install -Sy python3 python3-pip python3-devel python3-setuptools base-devel dmidecode
;; ;;
*) #Any other distro *) #Any other distro
manual_install manual_install

View File

@ -14,6 +14,7 @@ import warnings
import configparser import configparser
from math import isclose from math import isclose
from pathlib import Path from pathlib import Path
from shutil import which
from subprocess import getoutput, call, run, check_output, DEVNULL from subprocess import getoutput, call, run, check_output, DEVNULL
@ -293,18 +294,21 @@ def deploy_daemon():
# deploy cpufreqctl script func call # deploy cpufreqctl script func call
cpufreqctl() cpufreqctl()
print("* Turn off bluetooth on boot") if which("bluetoothctl") is not None:
btconf = Path("/etc/bluetooth/main.conf") print("* Turn off bluetooth on boot")
try: btconf = Path("/etc/bluetooth/main.conf")
orig_set = "AutoEnable=true" try:
change_set = "AutoEnable=false" orig_set = "AutoEnable=true"
with btconf.open(mode="r+") as f: change_set = "AutoEnable=false"
content = f.read() with btconf.open(mode="r+") as f:
f.seek(0) content = f.read()
f.truncate() f.seek(0)
f.write(content.replace(orig_set, change_set)) f.truncate()
except Exception as e: f.write(content.replace(orig_set, change_set))
print(f"\nERROR:\nWas unable to turn off bluetooth on boot\n{repr(e)}") except Exception as e:
print(f"\nERROR:\nWas unable to turn off bluetooth on boot\n{repr(e)}")
else:
print("* Turn off bluetooth on boot [skipping] (package providing bluetooth access is not present)")
auto_cpufreq_stats_path.touch(exist_ok=True) auto_cpufreq_stats_path.touch(exist_ok=True)
@ -329,18 +333,21 @@ def remove():
print("\n" + "-" * 21 + " Removing auto-cpufreq daemon " + "-" * 22 + "\n") print("\n" + "-" * 21 + " Removing auto-cpufreq daemon " + "-" * 22 + "\n")
print("* Turn on bluetooth on boot") if which("bluetoothctl") is not None:
btconf = "/etc/bluetooth/main.conf" print("* Turn on bluetooth on boot")
try: btconf = "/etc/bluetooth/main.conf"
orig_set = "AutoEnable=true" try:
change_set = "AutoEnable=false" orig_set = "AutoEnable=true"
with open(btconf, "r+") as f: change_set = "AutoEnable=false"
content = f.read() with open(btconf, "r+") as f:
f.seek(0) content = f.read()
f.truncate() f.seek(0)
f.write(content.replace(change_set, orig_set)) f.truncate()
except Exception as e: f.write(content.replace(change_set, orig_set))
print(f"\nERROR:\nWas unable to turn on bluetooth on boot\n{repr(e)}") except Exception as e:
print(f"\nERROR:\nWas unable to turn on bluetooth on boot\n{repr(e)}")
else:
print("* Turn on bluetooth on boot [skipping] (package providing bluetooth access is not present)")
# run auto-cpufreq daemon install script # run auto-cpufreq daemon install script
call("/usr/bin/auto-cpufreq-remove", shell=True) call("/usr/bin/auto-cpufreq-remove", shell=True)

View File

@ -37,7 +37,6 @@ sv_cmd() {
if [ "$(ps h -o comm 1)" = "runit" ];then if [ "$(ps h -o comm 1)" = "runit" ];then
if [ -f /etc/os-release ];then if [ -f /etc/os-release ];then
eval "$(cat /etc/os-release)" eval "$(cat /etc/os-release)"
separator
case $ID in case $ID in
void) void)
runit_ln /etc /var runit_ln /etc /var

View File

@ -25,7 +25,6 @@ rm_sv() {
if [ "$(ps h -o comm 1)" = "runit" ];then if [ "$(ps h -o comm 1)" = "runit" ];then
if [ -f /etc/os-release ];then if [ -f /etc/os-release ];then
eval "$(cat /etc/os-release)" eval "$(cat /etc/os-release)"
separator
case $ID in case $ID in
void) void)
rm_sv /etc /var ;; rm_sv /etc /var ;;