added notification as function helper
This commit is contained in:
48
.config/function_helper.sh
Normal file
48
.config/function_helper.sh
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Function to check if a directory is already mounted
|
||||||
|
function is_mounted() {
|
||||||
|
mountpoint -q "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to send a low-priority notification
|
||||||
|
function send_low_notification() {
|
||||||
|
local icon=${3:-"$HOME/.config/swaync/icons/low.png"}
|
||||||
|
notify-send -u low -i "$icon" "$1" "$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to send a normal notification
|
||||||
|
function send_normal_notification() {
|
||||||
|
local icon=${3:-"$HOME/.config/swaync/icons/normal.png"}
|
||||||
|
notify-send -u normal -i "$icon" "$1" "$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to send a high-priority notification
|
||||||
|
function send_high_notification() {
|
||||||
|
local icon=${3:-"$HOME/.config/swaync/icons/critical.png"}
|
||||||
|
notify-send -u critical -i "$icon" "$1" "$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main function to handle the logic
|
||||||
|
# Example: send_notification "low" "Upper Text" "Lower Text" "icon Path"
|
||||||
|
function send_notification() {
|
||||||
|
local priority=$1
|
||||||
|
local uppertext=$2
|
||||||
|
local lowertext=$3
|
||||||
|
local icon=$4
|
||||||
|
|
||||||
|
case $priority in
|
||||||
|
low)
|
||||||
|
send_low_notification "$uppertext" "$lowertext" "$icon"
|
||||||
|
;;
|
||||||
|
normal)
|
||||||
|
send_normal_notification "$uppertext" "$lowertext" "$icon"
|
||||||
|
;;
|
||||||
|
high)
|
||||||
|
send_high_notification "$uppertext" "$lowertext" "$icon"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {low|normal|high} 'Uppertext' 'Lowertext' [icon]"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user