#!/usr/bin/env sh # Set the directory paths waybar_dir=`dirname $(realpath $0)` modes_dir="$waybar_dir/modes" # Get the current symlink target current_target=$(readlink "$waybar_dir/config.jsonc") # Get the list of available files in modes directory file_list=("$modes_dir"/*.jsonc) num_files=${#file_list[@]} # Check if there are no files or only one file if [[ $num_files -eq 0 ]]; then echo "Error: No files found in modes directory." exit 1 elif [[ $num_files -eq 1 ]]; then echo "Only one file found. No changes made." exit 0 fi # Find the index of the current target in the file list current_index=-1 for ((i=0; i /dev/null 2>&1 &