diff --git a/install.sh b/install.sh index f56a8e2..803b1f0 100644 --- a/install.sh +++ b/install.sh @@ -18,6 +18,6 @@ if ! command -v ectool &> /dev/null; then fi echo "Installing kblight to /usr/local/bin" -curl -o /usr/local/bin/kblight "https://raw.githubusercontent.com/radeeyate/kblight/master/kblight.sh" +curl -o /usr/local/bin/kblight "https://raw.githubusercontent.com/radeeyate/kblight/master/kblight" echo "Done... exiting" exit 0 \ No newline at end of file diff --git a/kblight.sh b/kblight.sh deleted file mode 100644 index 278a365..0000000 --- a/kblight.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/bash - -ECTOOLURL="https://gitlab.howett.net/DHowett/ectool/-/jobs/890/artifacts/download?file_type=archive" -VERSION="1.0" -OPTIONS=("set" "get" "help" "version" "effect") - -# check for root -if [[ "$EUID" -ne 0 ]]; then - echo "This script must be run as root. Please use sudo." - exit 1 -fi - -if ! command -v ectool &> /dev/null; then - echo "ectool is not installed or was not found in your PATH" - echo "Downloading ectool to /usr/local/bin..." - mkdir -p /usr/local/bin - curl -L "$ECTOOLURL" -o ectool.zip - unzip -j ectool.zip _build/src/ectool -d /usr/local/bin - chmod +x /usr/local/bin/ectool - rm ectool.zip - echo "Done!" - exit 0 -fi - -# check for correct usage with "set", "help" or "version" -if [[ ! " ${OPTIONS[@]} " =~ " $1 " ]]; then - echo "Usage: kblight set " - echo "For help, run: kblight help" - exit 1 -fi - -if [[ "$1" == "help" ]]; then - echo "Usage: kblight set | get | help | version" - echo "" - echo "Available commands:" - echo "" - echo "- set : Sets the keyboard backlight to the specified level." - echo " - Available brightness levels:" - echo " - max: Sets brightness to maximum (100%)" - echo " - off: Turns off the backlight" - echo " - mid: Sets brightness to 50%" - echo " - low: Sets brightness to 20%" - echo " - dim: Sets brightness to 5%" - echo " - : Sets brightness to a specific percentage value (0-100)" - echo "" - echo "- effect : Sets the keyboard effect to the specified effect." - echo " - Available effects:" - echo " - strobe" - echo " - breathe" - echo "" - echo "- get: Gets the current keyboard backlight brightness as a percentage." - echo "- help: Displays this help message." - echo "- version: Displays the version information of kblight." - exit 0 -elif [[ "$1" == "version" ]]; then - echo "kblight $VERSION" - echo "Copyright (c) 2024 radi8" - echo "License: MIT" - exit 0 -elif [[ "$1" == "get" ]]; then - percentage=$(echo "$(ectool pwmgetkblight)" | grep -o -E '[0-9]+') - if [[ "$?" -eq 0 ]]; then - echo "Current keyboard backlight percentage is $percentage%" - else - echo "An error occured when getting the current backlight percentage" - exit 1 - fi -elif [[ "$1" == "set" ]]; then - shift - if [[ "$1" == "max" ]]; then - brightness=100 - elif [[ "$1" == "off" ]]; then - brightness=0 - elif [[ "$1" == "mid" ]]; then - brightness=50 - elif [[ "$1" == "low" ]]; then - brightness=20 - elif [[ "$1" == "dim" ]]; then - brightness=5 - else - if [[ ! "$1" =~ ^[0-9]+$ ]]; then - echo "Invalid input: Please provide a number between 0 and 100, or one of the following: max, off, mid, or low." - exit 1 - fi - brightness="$1" - - if [[ "$brightness" -gt 100 ]]; then - echo "Brightness cannot be higher than 100. Setting to maximum." - brightness=100 - fi - - if [[ "$brightness" -lt 0 ]]; then - echo "Brightness cannot be lower than 0. Turning off." - brightness=0 - fi - fi - - echo "Setting keyboard backlight brightness to $brightness%" - ectool pwmsetkblight "$brightness" > /dev/null - - if [[ "$?" -ne 0 ]]; then - echo "An error occured when setting your brightness to $brightness." - exit 1 - fi -elif [[ "$1" == "effect" ]]; then - shift - if [[ "$1" == "strobe" ]]; then - echo "Press Ctrl+C to stop strobe effect." - - while true; do - kblight set 0 > /dev/null - - if [[ "$?" -ne 0 ]]; then - echo "An error occured while trying to apply effect: strobe." - exit 1 - fi - - sleep 0.04 - kblight set 100 > /dev/null - sleep 0.04 - done - elif [[ "$1" == "breathe" ]]; then - echo "Press Ctrl+C to stop breathe effect." - - while true; do - for i in $(seq 0 1 100); do - kblight set "$i" > /dev/null - - if [[ "$?" -ne 0 ]]; then - echo "An error occured while trying to apply effect: breathe." - exit 1 - fi - - sleep 0.013 - done - for i in $(seq 100 -1 0); do - kblight set "$i" > /dev/null - sleep 0.013 - done - sleep 1.7 - done - else - echo "Invalid input. Please provide one of the following options: strobe or breathe." - exit 1 - fi -fi