From 36413d2a55a9c51f29d7a002c1f0081a791d713b Mon Sep 17 00:00:00 2001 From: clyhtsuriva Date: Thu, 4 May 2023 11:19:58 +0200 Subject: Improve update-scripts-rep.sh and added new script potentia displays battery level in the term + notification --- bin/potentia.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 bin/potentia.sh (limited to 'bin/potentia.sh') diff --git a/bin/potentia.sh b/bin/potentia.sh new file mode 100755 index 0000000..a6e3e68 --- /dev/null +++ b/bin/potentia.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# +# Clyhtsuriva +# +# +# -- potentia -- +# +# Displays the battery percentage in the terminal +# and as a notification. +# + +# An array containing the required programs +required_programs=("acpi" "notify-send") + +# Check if each program is installed +for program in "${required_programs[@]}"; do + if ! command -v "$program" &> /dev/null; then + echo "Error: $program is not installed. Please install $program and try again." + exit 1 + fi +done + +# Get the current battery percentage using acpi +battery_level=$(acpi | awk '{print $4}' | tr -d ',') + +# Display in the terminal +echo "Battery level: $battery_level" + +# Send a notification using notify-send +notify-send "Battery level: $battery_level" -- cgit v1.2.3