From c6aa25647e8c744d55b753b536fe01b225a93c95 Mon Sep 17 00:00:00 2001 From: Joel Mathew Thomas <90510078+joelmathewthomas@users.noreply.github.com> Date: Thu, 11 Apr 2024 00:22:49 +0530 Subject: [PATCH] added .local/bin/ for scripts --- .local/bin/fanctl | 62 ++++++++++++++++++++++++++++++++++++++++ .local/bin/fanstat | 12 ++++++++ .local/bin/gamemode | 14 +++++++++ .local/bin/stats/fanstat | 3 ++ 4 files changed, 91 insertions(+) create mode 100755 .local/bin/fanctl create mode 100755 .local/bin/fanstat create mode 100755 .local/bin/gamemode create mode 100644 .local/bin/stats/fanstat diff --git a/.local/bin/fanctl b/.local/bin/fanctl new file mode 100755 index 0000000..6ae8775 --- /dev/null +++ b/.local/bin/fanctl @@ -0,0 +1,62 @@ +#!/bin/bash + +# Function to check if a string is an integer +is_integer() { + [[ $1 =~ ^[0-9]+$ ]] +} + +# Function to format tooltip message (You need to define this function) +waybar_tooltip() { + # Replace this with your logic to format tooltip message if necessary + echo "$1" +} + +# Check if the correct number of arguments is provided +if [ $# -ne 1 ]; then + echo "Usage: $0 [min|max|auto|integer]" + exit 1 +fi + +# Initialize variables for the text, tooltip, and class +text="" +tooltip="" +class="" + +# Check the argument and execute the corresponding command +case $1 in + min) + nbfc set -f 0 1 -s 30 + text="min" + tooltip="30%" + class="min" + ;; + max) + nbfc set -f 0 1 -s 100 + text="max" + tooltip="100%" + class="max" + ;; + auto) + nbfc set -f 0 1 -a + text="auto" + tooltip="Auto" + class="auto" + ;; + *) + if is_integer "$1"; then # Check if argument is an integer + nbfc set -f 0 1 -s "$1" # Execute nbfc with the provided integer value + text="$1" + tooltip="$1%" + class="custom" + else + echo "Invalid argument. Usage: $0 [min|max|auto|integer]" + exit 1 + fi + ;; +esac + +# Output text, tooltip, and class to statfile +echo "text=$text" > ~/.local/bin/stats/fanstat +echo "tooltip=$(waybar_tooltip "$tooltip")" >> ~/.local/bin/stats/fanstat +echo "class=$class" >> ~/.local/bin/stats/fanstat + diff --git a/.local/bin/fanstat b/.local/bin/fanstat new file mode 100755 index 0000000..fd2ff6b --- /dev/null +++ b/.local/bin/fanstat @@ -0,0 +1,12 @@ +#!/bin/bash + +# Check if the file exists +if [ -f ~/.local/bin/fanctl ]; then + # Read the values of text, class, and tooltip + source ~/.local/bin/stats/fanstat + + # Output the values in JSON format using printf + printf '{"text": "%s", "tooltip": "%s", "class": "%s"}\n' "$text" "$tooltip" "$class" +else + echo "{\"error\": \"File not found\"}" +fi diff --git a/.local/bin/gamemode b/.local/bin/gamemode new file mode 100755 index 0000000..b89b5c4 --- /dev/null +++ b/.local/bin/gamemode @@ -0,0 +1,14 @@ +#!/usr/bin/env sh +HYPRGAMEMODE=$(hyprctl getoption animations:enabled | awk 'NR==1{print $2}') +if [ "$HYPRGAMEMODE" = 1 ] ; then + hyprctl --batch "\ + keyword animations:enabled 0;\ + keyword decoration:drop_shadow 0;\ + keyword decoration:blur:enabled 0;\ + keyword general:gaps_in 0;\ + keyword general:gaps_out 0;\ + keyword general:border_size 1;\ + keyword decoration:rounding 0" + exit +fi +hyprctl reload diff --git a/.local/bin/stats/fanstat b/.local/bin/stats/fanstat new file mode 100644 index 0000000..3b2e177 --- /dev/null +++ b/.local/bin/stats/fanstat @@ -0,0 +1,3 @@ +text=min +tooltip=30% +class=min