From 2ec4186e5c7880eda641e7843187a87fb5a6644b Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Sun, 3 Nov 2024 18:22:03 +0530 Subject: [PATCH 1/2] rework: auto-cpufreq --- core/tabs/applications-setup/auto-cpufreq.sh | 111 +++++++++++++++++++ core/tabs/applications-setup/tab_data.toml | 6 + core/tabs/utils/power-profile.sh | 98 ---------------- core/tabs/utils/tab_data.toml | 5 - docs/userguide.md | 2 + 5 files changed, 119 insertions(+), 103 deletions(-) create mode 100644 core/tabs/applications-setup/auto-cpufreq.sh delete mode 100644 core/tabs/utils/power-profile.sh diff --git a/core/tabs/applications-setup/auto-cpufreq.sh b/core/tabs/applications-setup/auto-cpufreq.sh new file mode 100644 index 00000000..14f67159 --- /dev/null +++ b/core/tabs/applications-setup/auto-cpufreq.sh @@ -0,0 +1,111 @@ +#!/bin/sh -e + +. ../common-script.sh + +installAutoCpufreq() { + clear + + AUTO_CPUFREQ_PATH="$HOME/.local/share/auto-cpufreq" + + if ! command_exists auto-cpufreq; then + printf "%b\n" "${YELLOW}Installing auto-cpufreq.${RC}" + + if ! command_exists git && [ "$PACKAGER" != "pacman" ]; then + printf "%b\n" "${YELLOW}Installing git.${RC}" + case "$PACKAGER" in + *) + "$ESCALATION_TOOL" "$PACKAGER" install -y git + ;; + esac + fi + + case "$PACKAGER" in + pacman) + if command_exists powerprofilesctl; then + printf "%b\n" "${YELLOW}Disabling powerprofilesctl service.${RC}" + "$ESCALATION_TOOL" systemctl disable --now power-profiles-daemon + fi + + "$AUR_HELPER" -S --needed --noconfirm auto-cpufreq + "$ESCALATION_TOOL" systemctl enable --now auto-cpufreq + ;; + *) + mkdir -p "$HOME/.local/share" + + if [ -d "$AUTO_CPUFREQ_PATH" ]; then + rm -rf "$AUTO_CPUFREQ_PATH" + fi + + printf "%b\n" "${YELLOW}Cloning auto-cpufreq repository.${RC}" + git clone --depth=1 https://github.com/AdnanHodzic/auto-cpufreq.git "$AUTO_CPUFREQ_PATH" + + cd "$AUTO_CPUFREQ_PATH" + printf "%b\n" "${YELLOW}Running auto-cpufreq installer.${RC}" + "$ESCALATION_TOOL" ./auto-cpufreq-installer + "$ESCALATION_TOOL" auto-cpufreq --install + ;; + esac + else + printf "%b\n" "${GREEN}auto-cpufreq is already installed.${RC}" + fi +} + +applyTweak() { + printf "%b\n" "${YELLOW}Configuring auto-cpufreq.${RC}" + + if command_exists auto-cpufreq; then + if [ -d /sys/class/power_supply/BAT0 ]; then + printf "%b\n" "${GREEN}System detected as laptop. Updating auto-cpufreq for laptop.${RC}" + "$ESCALATION_TOOL" auto-cpufreq --force powersave + else + printf "%b\n" "${GREEN}System detected as desktop. Updating auto-cpufreq for desktop.${RC}" + "$ESCALATION_TOOL" auto-cpufreq --force performance + fi + else + printf "%b\n" "${RED}auto-cpufreq is not installed.${RC}" + exit 1 + fi +} + +removeTweak() { + if command_exists auto-cpufreq; then + printf "%b\n" "${YELLOW}Removing auto-cpufreq tweak.${RC}" + "$ESCALATION_TOOL" auto-cpufreq --force reset + else + printf "%b\n" "${RED}auto-cpufreq is not installed.${RC}" + exit 1 + fi +} + +main() { + printf "%b\n" "${YELLOW}Do you want to apply the auto-cpufreq tweak or remove it?${RC}" + printf "%b\n" "${YELLOW}1) Apply tweak${RC}" + printf "%b\n" "${YELLOW}2) Remove tweak${RC}" + printf "%b\n" "${YELLOW}3) Exit${RC}" + printf "%b" "Enter your choice [1/3]: " + read -r choice + + case "$choice" in + 1) + applyTweak + ;; + 2) + removeTweak + ;; + 3) + printf "%b\n" "${GREEN}Exiting.${RC}" + exit 0 + ;; + *) + printf "%b\n" "${RED}Invalid choice. Exiting.${RC}" + exit 1 + ;; + esac + + printf "%b\n" "${GREEN}auto-cpufreq setup complete.${RC}" +} + +checkEnv +checkEscalationTool +installAutoCpufreq +main diff --git a/core/tabs/applications-setup/tab_data.toml b/core/tabs/applications-setup/tab_data.toml index 44b74464..3f695734 100644 --- a/core/tabs/applications-setup/tab_data.toml +++ b/core/tabs/applications-setup/tab_data.toml @@ -210,6 +210,12 @@ description = "Universal Android Debloater (UAD) is a tool designed to help user script = "android-debloat.sh" task_list = "I" +[[data]] +name = "Auto CPU Frequency" +description = "Automatic CPU speed & power optimizer.\nhttps://github.com/AdnanHodzic/auto-cpufreq" +script = "auto-cpufreq.sh" +task_list = "I SS" + [[data]] name = "Bash Prompt" description = "The .bashrc file is a script that runs every time a new terminal session is started in Unix-like operating systems.\nIt is used to configure the shell session, set up aliases, define functions, and more, making the terminal easier to use and more powerful.\nThis command configures the key sections and functionalities defined in the .bashrc file from CTT's mybash repository.\nhttps://github.com/ChrisTitusTech/mybash" diff --git a/core/tabs/utils/power-profile.sh b/core/tabs/utils/power-profile.sh deleted file mode 100644 index 536f7c69..00000000 --- a/core/tabs/utils/power-profile.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/sh -e - -. ../common-script.sh - -installAutoCpufreq() { - clear - printf "%b\n" "${YELLOW}Checking if auto-cpufreq is already installed...${RC}" - - # Check if auto-cpufreq is already installed - if command_exists auto-cpufreq; then - printf "%b\n" "${GREEN}auto-cpufreq is already installed.${RC}" - else - printf "%b\n" "${YELLOW}Installing auto-cpufreq...${RC}" - - # Install git if not already installed - if ! command_exists git; then - printf "%b\n" "${YELLOW}git not found. Installing git...${RC}" - case "$PACKAGER" in - pacman) - "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm git - ;; - *) - "$ESCALATION_TOOL" "$PACKAGER" install -y git - ;; - esac - fi - - # Clone the auto-cpufreq repository and run the installer - if [ ! -d "auto-cpufreq" ]; then - printf "%b\n" "${YELLOW}Cloning auto-cpufreq repository...${RC}" - git clone https://github.com/AdnanHodzic/auto-cpufreq.git - fi - - cd auto-cpufreq - printf "%b\n" "${YELLOW}Running auto-cpufreq installer...${RC}" - "$ESCALATION_TOOL" ./auto-cpufreq-installer - "$ESCALATION_TOOL" auto-cpufreq --install - - cd .. - fi -} - -configureAutoCpufreq() { - printf "%b\n" "${YELLOW}Configuring auto-cpufreq...${RC}" - - if command_exists auto-cpufreq; then - # Check if the system has a battery to determine if it's a laptop - if [ -d /sys/class/power_supply/BAT0 ]; then - printf "%b\n" "${GREEN}System detected as laptop. Updating auto-cpufreq for laptop...${RC}" - "$ESCALATION_TOOL" auto-cpufreq --force powersave - else - printf "%b\n" "${GREEN}System detected as desktop. Updating auto-cpufreq for desktop...${RC}" - "$ESCALATION_TOOL" auto-cpufreq --force performance - fi - else - printf "%b\n" "${RED}auto-cpufreq is not installed, skipping configuration.${RC}" - fi -} - -removeAutoCpufreqTweak() { - printf "%b\n" "${YELLOW}Removing auto-cpufreq tweak...${RC}" - - if command_exists auto-cpufreq; then - printf "%b\n" "${YELLOW}Resetting auto-cpufreq configuration...${RC}" - "$ESCALATION_TOOL" auto-cpufreq --force reset - else - printf "%b\n" "${RED}auto-cpufreq is not installed, skipping removal.${RC}" - fi -} - -apply_or_remove_auto_cpufreq() { - # Prompt user for action - printf "%b\n" "${YELLOW}Do you want to apply the auto-cpufreq tweak or remove it?${RC}" - printf "%b\n" "${YELLOW}1) Apply tweak${RC}" - printf "%b\n" "${YELLOW}2) Remove tweak${RC}" - printf "%b" "Enter your choice [1/2]: " - read -r choice - - case $choice in - 1) - configureAutoCpufreq - ;; - 2) - removeAutoCpufreqTweak - ;; - *) - printf "%b\n" "${RED}Invalid choice. Exiting.${RC}" - exit 1 - ;; - esac - - printf "%b\n" "${GREEN}auto-cpufreq setup complete.${RC}" -} - -checkEnv -checkEscalationTool -installAutoCpufreq -apply_or_remove_auto_cpufreq diff --git a/core/tabs/utils/tab_data.toml b/core/tabs/utils/tab_data.toml index 00b68edf..fdf82275 100644 --- a/core/tabs/utils/tab_data.toml +++ b/core/tabs/utils/tab_data.toml @@ -110,11 +110,6 @@ name = "Auto Login" script = "auto-login.sh" task_list = "DE setup" -[[data]] -name = "Auto Power Profiling" -script = "power-profile.sh" -task_list = "I" - [[data]] name = "Bluetooth Manager" description = "This utility is designed to manage bluetooth in your system" diff --git a/docs/userguide.md b/docs/userguide.md index 8ad704e6..2d9279fc 100644 --- a/docs/userguide.md +++ b/docs/userguide.md @@ -48,6 +48,8 @@ https://github.com/ChrisTitusTech/neovim - **Alacritty**: Alacritty is a modern terminal emulator that comes with sensible defaults, but allows for extensive configuration. By integrating with other applications, rather than reimplementing their functionality, it manages to provide a flexible set of features with high performance. The supported platforms currently consist of BSD, Linux, macOS and Windows. This command installs and condifures alacritty terminal emulator. - **Android Debloater**: Universal Android Debloater (UAD) is a tool designed to help users remove bloatware and unnecessary pre-installed applications from Android devices, enhancing performance and user experience. +- **Auto CPU Frequency**: Automatic CPU speed & power optimizer. +https://github.com/AdnanHodzic/auto-cpufreq - **Bash Prompt**: The .bashrc file is a script that runs every time a new terminal session is started in Unix-like operating systems. It is used to configure the shell session, set up aliases, define functions, and more, making the terminal easier to use and more powerful. This command configures the key sections and functionalities defined in the .bashrc file from CTT's mybash repository. From 4d9afd87833a0a1ab3422b5041c451a230ca18df Mon Sep 17 00:00:00 2001 From: Jeevitha Kannan K S Date: Sat, 9 Nov 2024 09:23:47 +0530 Subject: [PATCH 2/2] Revert changes to userguide auto-cpufreq --- docs/userguide.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/userguide.md b/docs/userguide.md index 8f98f101..11e598f8 100644 --- a/docs/userguide.md +++ b/docs/userguide.md @@ -48,8 +48,6 @@ https://github.com/ChrisTitusTech/neovim - **waterfox**: Waterfox is the privacy-focused web browser engineered to give you speed, control, and peace of mind on the internet. - **Alacritty**: Alacritty is a modern terminal emulator that comes with sensible defaults, but allows for extensive configuration. By integrating with other applications, rather than reimplementing their functionality, it manages to provide a flexible set of features with high performance. The supported platforms currently consist of BSD, Linux, macOS and Windows. This command installs and configures alacritty terminal emulator. - **Android Debloater**: Universal Android Debloater (UAD) is a tool designed to help users remove bloatware and unnecessary pre-installed applications from Android devices, enhancing performance and user experience. -- **Auto CPU Frequency**: Automatic CPU speed & power optimizer. -https://github.com/AdnanHodzic/auto-cpufreq - **Bash Prompt**: The .bashrc file is a script that runs every time a new terminal session is started in Unix-like operating systems. It is used to configure the shell session, set up aliases, define functions, and more, making the terminal easier to use and more powerful. This command configures the key sections and functionalities defined in the .bashrc file from CTT's mybash repository. https://github.com/ChrisTitusTech/mybash - **Bottles**: Bottles allows Windows software, like applications and games, to run on Linux. Bottles also provides tools to categorize, organize and optimize your applications. - **Docker**: Docker is an open platform that uses OS-level virtualization to deliver software in packages called containers.