some changes within scripts
This commit is contained in:
parent
643eaa2f9e
commit
7d6d263d71
6 changed files with 229 additions and 20 deletions
83
.scripts/bar
Executable file
83
.scripts/bar
Executable file
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Logging helper
|
||||
log_notify() {
|
||||
level="$1" # e.g., low, normal, critical
|
||||
title="$2"
|
||||
message="$3"
|
||||
notify-send -u "$level" "$title" "$message"
|
||||
}
|
||||
|
||||
# Check if the given command exists silently
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Function to handle errors
|
||||
handle_error() {
|
||||
local exit_code=$1
|
||||
local command_name=$2
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
log_notify "critical" "Error" "Failed to execute $command_name"
|
||||
exit $exit_code
|
||||
fi
|
||||
}
|
||||
|
||||
# fallback() {
|
||||
# if command_exists hyprpanel; then
|
||||
# pkill hyprpanel
|
||||
# handle_error $? "pkill hyprpanel"
|
||||
# hyprpanel &
|
||||
# handle_error $? "hyprpanel"
|
||||
# elif command_exists gBar; then
|
||||
# pkill gBar
|
||||
# handle_error $? "pkill gBar"
|
||||
# gBar bar 0 &
|
||||
# handle_error $? "gBar bar 0"
|
||||
# elif command_exists waybar; then
|
||||
# pkill waybar
|
||||
# handle_error $? "pkill waybar"
|
||||
# waybar &
|
||||
# handle_error $? "waybar"
|
||||
# else
|
||||
# log_notify "critical" "Error" "No compatible bar found"
|
||||
# exit 1
|
||||
# fi
|
||||
# }
|
||||
|
||||
barsetup() {
|
||||
local bar="${1:-hyprpanel}"
|
||||
|
||||
case "$bar" in
|
||||
hyprpanel)
|
||||
pkill hyprpanel
|
||||
# handle_error $? "pkill hyprpanel"
|
||||
hyprpanel &
|
||||
handle_error $? "hyprpanel"
|
||||
;;
|
||||
gBar)
|
||||
pkill gBar
|
||||
handle_error $? "pkill gBar"
|
||||
gBar bar 0 &
|
||||
handle_error $? "gBar bar 0"
|
||||
;;
|
||||
waybar)
|
||||
pkill waybar
|
||||
handle_error $? "pkill waybar"
|
||||
waybar &
|
||||
handle_error $? "waybar"
|
||||
;;
|
||||
*)
|
||||
pkill $bar
|
||||
# handle_error $? "pkill $bar"
|
||||
$bar &
|
||||
handle_error $? "$bar"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
if barsetup "$@"; then
|
||||
log_notify "normal" "Status-Bar" "initialized $bar"
|
||||
else
|
||||
log_notify "critical" "Status-Bar" "Something went wrong, your bar is probably not up.. sorry.."
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue