irongit
hygoland/scripts/WaybarScripts.sh
41 lines1.3 KBBourne Again Shell (bash)
1#!/bin/bash
2# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ #
3# This file used on waybar modules sourcing defaults set in $HOME/.config/hypr/UserConfigs/01-UserDefaults.conf
4
5# Define the path to the config file
6config_file=$HOME/.config/hypr/UserConfigs/01-UserDefaults.conf
7
8# Check if the config file exists
9if [[ ! -f "$config_file" ]]; then
10 echo "Error: Configuration file not found!"
11 exit 1
12fi
13
14# Process the config file in memory, removing the $ and fixing spaces
15config_content=$(sed 's/\$//g' "$config_file" | sed 's/ = /=/')
16
17# Source the modified content directly from the variable
18eval "$config_content"
19
20# Check if $term is set correctly
21if [[ -z "$term" ]]; then
22 echo "Error: \$term is not set in the configuration file!"
23 exit 1
24fi
25
26# Execute accordingly based on the passed argument
27if [[ "$1" == "--btop" ]]; then
28 $term --title btop sh -c 'btop'
29elif [[ "$1" == "--nvtop" ]]; then
30 $term --title nvtop sh -c 'nvtop'
31elif [[ "$1" == "--nmtui" ]]; then
32 $term nmtui
33elif [[ "$1" == "--term" ]]; then
34 $term &
35else
36 echo "Usage: $0 [--btop | --nvtop | --nmtui | --term]"
37 echo "--btop : Open btop in a new term"
38 echo "--nvtop : Open nvtop in a new term"
39 echo "--nmtui : Open nmtui in a new term"
40 echo "--term : Launch a term window"
41fi