diff --git a/.config/hypr/scripts/hyprfreeze b/.config/hypr/scripts/hyprfreeze index 39e3d102..85ad5bd9 100755 --- a/.config/hypr/scripts/hyprfreeze +++ b/.config/hypr/scripts/hyprfreeze @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash function printHelp() { cat </dev/null && echo "Resumed $(ps -p "$PID" -o comm= 2>/dev/null) (PID $PID)" || exit 1 - else - debugPrint "Suspending processes..." - kill -STOP $PIDS 2>/dev/null && echo "Suspended $(ps -p "$PID" -o comm= 2>/dev/null) (PID $PID)" || exit 1 - fi + # Suspend or resume processes + if [[ "$(ps -o state= "$PID")" == T ]]; then + debugPrint "Resuming processes..." + kill -CONT $PIDS 2>/dev/null && echo "Resumed $(ps -p "$PID" -o comm= 2>/dev/null) (PID $PID)" || exit 1 + else + debugPrint "Suspending processes..." + kill -STOP $PIDS 2>/dev/null && echo "Suspended $(ps -p "$PID" -o comm= 2>/dev/null) (PID $PID)" || exit 1 + fi } function getPidByActive() { - debugPrint "Getting PID by active window..." - PID=$(hyprctl activewindow -j | jq '.pid') - debugPrint "PID by active window: $PID" + debugPrint "Getting PID by active window..." + PID=$(hyprctl activewindow -j | jq '.pid') + debugPrint "PID by active window: $PID" } function getPidByPid() { - debugPrint "Getting PID by PID: $1" - # Check if process pid exists - if ! ps -p "$1" &>/dev/null; then - echo "Process ID $1 not found" - exit 1 - fi + debugPrint "Getting PID by PID: $1" + # Check if process pid exists + if ! ps -p "$1" &>/dev/null; then + echo "Process ID $1 not found" + exit 1 + fi - PID=$1 + PID=$1 } function getPidByName() { - debugPrint "Getting PID by name: $1" - # Check if process name exists - if ! pidof -x "$1" >/dev/null; then - echo "Process name $1 not found" - exit 1 - fi + debugPrint "Getting PID by name: $1" + # Check if process name exists + if ! pidof -x "$1" >/dev/null; then + echo "Process name $1 not found" + exit 1 + fi - # Get last process if there are multiple - PID=$(pidof "$1" | awk '{print $NF}') - debugPrint "PID by name: $PID" + # Get last process if there are multiple + PID=$(pidof "$1" | awk '{print $NF}') + debugPrint "PID by name: $PID" } function getPidByProp() { - debugPrint "Getting PID by prop..." - if ! command -v hyprprop; then - echo "You need to install 'hyprprop' to use this feature. (https://github.com/vilari-mickopf/hyprprop)" - exit 1 - fi + debugPrint "Getting PID by prop..." + if ! command -v hyprprop; then + echo "You need to install 'hyprprop' to use this feature. (https://github.com/vilari-mickopf/hyprprop)" + exit 1 + fi - PID=$(hyprprop | jq '.pid') - debugPrint "PID by prop: $PID" + PID=$(hyprprop | jq '.pid') + debugPrint "PID by prop: $PID" } function printInfo() { - debugPrint "Printing process info...\n" - echo -e "$(tput bold)Process tree:$(tput sgr0)" - ps -p "$PID" 2>/dev/null && pstree -p "$PID" + debugPrint "Printing process info...\n" + echo -e "$(tput bold)Process tree:$(tput sgr0)" + ps -p "$PID" 2>/dev/null && pstree -p "$PID" - echo -e "\n$(tput bold)Process threads:$(tput sgr0)" - ps -eLo pid,tid,comm | grep "$PID" 2>/dev/null + echo -e "\n$(tput bold)Process threads:$(tput sgr0)" + ps -eLo pid,tid,comm | grep "$PID" 2>/dev/null - echo -e "\n$(tput bold)Process ID$(tput sgr0) = $PID \ + echo -e "\n$(tput bold)Process ID$(tput sgr0) = $PID \ \n$(tput bold)Process name$(tput sgr0) = $(ps -p "$PID" -o comm= 2>/dev/null) \ \n$(tput bold)Process state$(tput sgr0) = $(ps -o state= -p "$PID" 2>/dev/null)\n" } function sendNotification() { - debugPrint "Sending notification..." - local title - title=$( [[ "$(ps -p "$PID" -o state=)" == T ]] && - echo "Suspended $(ps -p "$PID" -o comm= 2>/dev/null)" || - echo "Resumed $(ps -p "$PID" -o comm= 2>/dev/null)") + debugPrint "Sending notification..." + local title + title=$([[ "$(ps -p "$PID" -o state=)" == T ]] && + echo "Suspended $(ps -p "$PID" -o comm= 2>/dev/null)" || + echo "Resumed $(ps -p "$PID" -o comm= 2>/dev/null)") - local message="PID $PID" + local message="PID $PID" - notify-send "${title}" "${message}" -t "$NOTIF_TIMEOUT" -a Hyprfreeze + notify-send "${title}" "${message}" -t "$NOTIF_TIMEOUT" -a Hyprfreeze } function args() { - # Track required flags - local required_flag_count=0 + # Track required flags + local required_flag_count=0 - # Parse options - local options="hap:n:rst:" - local long_options="help,active,pid:,name:,prop,silent,notif-timeout:,info,dry-run,debug" - local parsed_args - parsed_args=$(getopt -o "$options" --long "$long_options" -n "$(basename "$0")" -- "$@") + # Parse options + local options="hap:n:rst:" + local long_options="help,active,pid:,name:,prop,silent,notif-timeout:,info,dry-run,debug" + local parsed_args + parsed_args=$(getopt -o "$options" --long "$long_options" -n "$(basename "$0")" -- "$@") - eval set -- "$parsed_args" - while true; do - case $1 in - -h | --help) - printHelp - exit 0 - ;; - -a | --active) - ((required_flag_count++)) - FLAG_ACTIVE=true - ;; - -p | --pid) - ((required_flag_count++)) - shift - FLAG_PID="$1" - ;; - -n | --name) - ((required_flag_count++)) - shift - NAME_FLAG="$1" - ;; - -r | --prop) - ((required_flag_count++)) - FLAG_PROP=true - ;; - -s | --silent) - SILENT=1 - ;; - -t | --notif-timeout) - shift - NOTIF_TIMEOUT="$1" - ;; - --info) - INFO=1 - ;; - --dry-run) - DRYRUN=1 - ;; - --debug) - DEBUG=1 - ;; - --) - shift # Skip -- argument - break - ;; - *) - exit 1 - ;; - esac - shift - done + eval set -- "$parsed_args" + while true; do + case $1 in + -h | --help) + printHelp + exit 0 + ;; + -a | --active) + ((required_flag_count++)) + FLAG_ACTIVE=true + ;; + -p | --pid) + ((required_flag_count++)) + shift + FLAG_PID="$1" + ;; + -n | --name) + ((required_flag_count++)) + shift + NAME_FLAG="$1" + ;; + -r | --prop) + ((required_flag_count++)) + FLAG_PROP=true + ;; + -s | --silent) + SILENT=1 + ;; + -t | --notif-timeout) + shift + NOTIF_TIMEOUT="$1" + ;; + --info) + INFO=1 + ;; + --dry-run) + DRYRUN=1 + ;; + --debug) + DEBUG=1 + ;; + --) + shift # Skip -- argument + break + ;; + *) + exit 1 + ;; + esac + shift + done - # Check if more than one required flag is provided, or if none was provided - if [ $required_flag_count -ne 1 ]; then - printHelp - exit 1 - fi + # Check if more than one required flag is provided, or if none was provided + if [ $required_flag_count -ne 1 ]; then + printHelp + exit 1 + fi } function main() { - debugPrint "Starting main function..." - # Get pid by a required flag - if [ "$FLAG_ACTIVE" = true ]; then - getPidByActive - elif [ -n "$FLAG_PID" ]; then - getPidByPid "$FLAG_PID" - elif [ -n "$NAME_FLAG" ]; then - getPidByName "$NAME_FLAG" - elif [ "$FLAG_PROP" = true ]; then - getPidByProp - fi + debugPrint "Starting main function..." + # Get pid by a required flag + if [ "$FLAG_ACTIVE" = true ]; then + getPidByActive + elif [ -n "$FLAG_PID" ]; then + getPidByPid "$FLAG_PID" + elif [ -n "$NAME_FLAG" ]; then + getPidByName "$NAME_FLAG" + elif [ "$FLAG_PROP" = true ]; then + getPidByProp + fi - # Suspend or resume process - toggleFreeze + # Suspend or resume process + toggleFreeze - # Run these functions after PID is obtained - if [ $INFO -eq 1 ]; then printInfo; fi - if [ $SILENT -ne 1 ]; then sendNotification; fi + # Run these functions after PID is obtained + if [ $INFO -eq 1 ]; then printInfo; fi + if [ $SILENT -ne 1 ]; then sendNotification; fi - debugPrint "End of main function." + debugPrint "End of main function." } SILENT=0 diff --git a/.config/hypr/scripts/hyprshot b/.config/hypr/scripts/hyprshot index 50c217dc..28b67a3a 100755 --- a/.config/hypr/scripts/hyprshot +++ b/.config/hypr/scripts/hyprshot @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash set -e diff --git a/.config/hypr/scripts/move_by_rules b/.config/hypr/scripts/move_by_rules index 5084afd0..637fbb96 100755 --- a/.config/hypr/scripts/move_by_rules +++ b/.config/hypr/scripts/move_by_rules @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/bin/bash # Script created by: https://github.com/moguay diff --git a/.config/rg/.ripgreprc b/.config/rg/.ripgreprc index 6cf357cb..5f0ad8bf 100644 --- a/.config/rg/.ripgreprc +++ b/.config/rg/.ripgreprc @@ -1,3 +1,3 @@ -#!/usr/bin/bash +#!/bin/bash --smart-case diff --git a/.local/bin/color-scripts/bars b/.local/bin/color-scripts/bars index 92750f6b..499cd020 100755 --- a/.local/bin/color-scripts/bars +++ b/.local/bin/color-scripts/bars @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # ANSI color scheme script by pfh # Source: http://crunchbang.org/forums/viewtopic.php?pid=139126#p139126 diff --git a/.local/bin/color-scripts/blacklisted/awk-rgb-test b/.local/bin/color-scripts/blacklisted/awk-rgb-test index 5853e6bc..3fabe214 100755 --- a/.local/bin/color-scripts/blacklisted/awk-rgb-test +++ b/.local/bin/color-scripts/blacklisted/awk-rgb-test @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash echo "This should be a smooth gradient" echo "" awk 'BEGIN{ diff --git a/.local/bin/color-scripts/blacklisted/hex b/.local/bin/color-scripts/blacklisted/hex index a8dcb23b..411196af 100755 --- a/.local/bin/color-scripts/blacklisted/hex +++ b/.local/bin/color-scripts/blacklisted/hex @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Author: SuNjACk # Source: http://crunchbang.org/forums/viewtopic.php?pid=135226#p135226 diff --git a/.local/bin/color-scripts/blacklisted/print256 b/.local/bin/color-scripts/blacklisted/print256 index 9e2c0aef..c33e448c 100755 --- a/.local/bin/color-scripts/blacklisted/print256 +++ b/.local/bin/color-scripts/blacklisted/print256 @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Tom Hale, 2016. MIT Licence. # Print out 256 colours, with each number printed in its corresponding colour diff --git a/.local/bin/color-scripts/blacklisted/suckless b/.local/bin/color-scripts/blacklisted/suckless index dbc59be8..72ffccd1 100755 --- a/.local/bin/color-scripts/blacklisted/suckless +++ b/.local/bin/color-scripts/blacklisted/suckless @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Author: HostGrady # Font used: https://patorjk.com/software/taag/#p=display&f=Cricket&t=suckless diff --git a/.local/bin/color-scripts/blocks1 b/.local/bin/color-scripts/blocks1 index 785fe0ce..3e1ad5b1 100755 --- a/.local/bin/color-scripts/blocks1 +++ b/.local/bin/color-scripts/blocks1 @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash pcs() { for i in {0..7}; do echo -en "\e[${1}$((30+$i))m \u2588\u2588 \e[0m"; done; } pcsbright() { for i in {0..7}; do echo -en "\e[${1}$((90+$i))m \u2588\u2588 \e[0m"; done; } printf "\n%s\n%s\n\n" "$(pcs)" "$(pcsbright '1;')" diff --git a/.local/bin/color-scripts/bloks b/.local/bin/color-scripts/bloks index 1c379531..13accfa0 100755 --- a/.local/bin/color-scripts/bloks +++ b/.local/bin/color-scripts/bloks @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # ANSI Color -- use these variables to easily have different color # and format output. Make sure to output the reset sequence after diff --git a/.local/bin/color-scripts/colortest b/.local/bin/color-scripts/colortest index 2c89f9a6..dc83a92a 100755 --- a/.local/bin/color-scripts/colortest +++ b/.local/bin/color-scripts/colortest @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Daniel Crisman's ANSI color chart script from # The Bash Prompt HOWTO: 6.1. Colours diff --git a/.local/bin/color-scripts/colortest-slim b/.local/bin/color-scripts/colortest-slim index 965beb6a..7dc74e7c 100755 --- a/.local/bin/color-scripts/colortest-slim +++ b/.local/bin/color-scripts/colortest-slim @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Author: machinebacon # Source: http://linuxbbq.org/bbs/viewtopic.php?f=4&t=1656#p33237 diff --git a/.local/bin/color-scripts/colorview b/.local/bin/color-scripts/colorview index 5a2c20e9..e1778a22 100755 --- a/.local/bin/color-scripts/colorview +++ b/.local/bin/color-scripts/colorview @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Original: http://frexx.de/xterm-256-notes/ # http://frexx.de/xterm-256-notes/data/colortable16.sh diff --git a/.local/bin/color-scripts/crowns b/.local/bin/color-scripts/crowns index 848ba746..cfdad288 100755 --- a/.local/bin/color-scripts/crowns +++ b/.local/bin/color-scripts/crowns @@ -1,8 +1,8 @@ -#!/usr/bin/env bash +#!/bin/bash # Author: venam -cat << EOF +cat <