aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/MonitorProfiles.sh
diff options
context:
space:
mode:
Diffstat (limited to 'config/hypr/scripts/MonitorProfiles.sh')
-rwxr-xr-xconfig/hypr/scripts/MonitorProfiles.sh53
1 files changed, 47 insertions, 6 deletions
diff --git a/config/hypr/scripts/MonitorProfiles.sh b/config/hypr/scripts/MonitorProfiles.sh
index 78825986..6330d45c 100755
--- a/config/hypr/scripts/MonitorProfiles.sh
+++ b/config/hypr/scripts/MonitorProfiles.sh
@@ -12,13 +12,46 @@ if pidof rofi > /dev/null; then
pkill rofi
fi
+# Detect active Hyprland config mode (Lua entrypoint vs legacy .conf includes)
+config_home="${XDG_CONFIG_HOME:-$HOME/.config}"
+hypr_dir="$config_home/hypr"
+lua_entry="$hypr_dir/hyprland.lua"
+legacy_lua_entry="$config_home/hyprland.lua"
+if [[ -n "$HYPR_CONFIG_MODE" ]]; then
+ case "${HYPR_CONFIG_MODE,,}" in
+ lua) hypr_config_mode="lua" ;;
+ conf|hyprlang) hypr_config_mode="conf" ;;
+ auto) hypr_config_mode="" ;;
+ *) hypr_config_mode="" ;;
+ esac
+fi
+
+if [[ -z "$hypr_config_mode" ]]; then
+ if [[ -f "$lua_entry" || -f "$legacy_lua_entry" ]]; then
+ hypr_config_mode="lua"
+ else
+ hypr_config_mode="conf"
+ fi
+fi
+
# Variables
iDIR="$HOME/.config/swaync/images"
SCRIPTSDIR="$HOME/.config/hypr/scripts"
monitor_dir="$HOME/.config/hypr/Monitor_Profiles"
-target="$HOME/.config/hypr/monitors.conf"
+target_conf="$HOME/.config/hypr/monitors.conf"
+target_lua_user="$HOME/.config/hypr/UserConfigs/monitors.lua"
+target_lua_legacy="$HOME/.config/hypr/lua/monitors.lua"
rofi_theme="$HOME/.config/rofi/config-Monitors.rasi"
-msg='❗NOTE:❗ This will overwrite $HOME/.config/hypr/monitors.conf'
+
+if [[ "$hypr_config_mode" == "lua" ]]; then
+ profile_ext="lua"
+ target="$target_lua_user"
+ msg="❗NOTE:❗ This will overwrite $HOME/.config/hypr/UserConfigs/monitors.lua"
+else
+ profile_ext="conf"
+ target="$target_conf"
+ msg="❗NOTE:❗ This will overwrite $HOME/.config/hypr/monitors.conf"
+fi
# Define the list of files to ignore
ignore_files=(
@@ -26,22 +59,30 @@ ignore_files=(
)
# list of Monitor Profiles, sorted alphabetically with numbers first
-mon_profiles_list=$(find -L "$monitor_dir" -maxdepth 1 -type f | sed 's/.*\///' | sed 's/\.conf$//' | sort -V)
+mon_profiles_list=$(find -L "$monitor_dir" -maxdepth 1 -type f -name "*.${profile_ext}" | sed 's/.*\///' | sed "s/\.${profile_ext}$//" | sort -V)
# Remove ignored files from the list
for ignored_file in "${ignore_files[@]}"; do
mon_profiles_list=$(echo "$mon_profiles_list" | grep -v -E "^$ignored_file$")
done
+if [[ -z "$mon_profiles_list" ]]; then
+ notify-send -u low -i "$iDIR/ja.png" "Monitor Profiles" "No .${profile_ext} profiles found in $monitor_dir"
+ exit 1
+fi
# Rofi Menu
-chosen_file=$(echo "$mon_profiles_list" | rofi -i -dmenu -config $rofi_theme -mesg "$msg")
+chosen_file=$(echo "$mon_profiles_list" | rofi -i -dmenu -config "$rofi_theme" -mesg "$msg")
if [[ -n "$chosen_file" ]]; then
- full_path="$monitor_dir/$chosen_file.conf"
+ full_path="$monitor_dir/$chosen_file.$profile_ext"
+ mkdir -p "$(dirname "$target")"
cp "$full_path" "$target"
+ if [[ "$hypr_config_mode" == "lua" && -f "$target_lua_legacy" ]]; then
+ cp "$full_path" "$target_lua_legacy"
+ fi
notify-send -u low -i "$iDIR/ja.png" "$chosen_file" "Monitor Profile Loaded"
fi
sleep 1
-${SCRIPTSDIR}/RefreshNoWaybar.sh & \ No newline at end of file
+"${SCRIPTSDIR}/RefreshNoWaybar.sh" &
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage