From 07028aec4f718607e462163785e8c2fb2039d8c2 Mon Sep 17 00:00:00 2001 From: churchy <129511714+nicefaa6waa@users.noreply.github.com> Date: Sat, 20 Jul 2024 12:48:33 +0300 Subject: [PATCH] Update changeres.sh --- .config/ags/modules/sideleft/tools/changeres.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.config/ags/modules/sideleft/tools/changeres.sh b/.config/ags/modules/sideleft/tools/changeres.sh index 0c086c30a..333f09881 100644 --- a/.config/ags/modules/sideleft/tools/changeres.sh +++ b/.config/ags/modules/sideleft/tools/changeres.sh @@ -33,9 +33,20 @@ update_resolution_config() { exit 1 fi + # Extract the resolution and refresh rate from the modeline + local resolution + resolution=$(echo "$modeline" | grep -oP '^[0-9]+x[0-9]+') + local rate + rate=$(echo "$modeline" | grep -oP '[0-9]+.[0-9]+$') + + if [ -z "$resolution" ] || [ -z "$rate" ]; then + echo "Failed to extract resolution or refresh rate from modeline" + exit 1 + fi + local configPath="${HOME}/.config/hypr/hyprland/general.conf" local newConfigContent - newConfigContent=$(sed "s/^monitor=.*$/monitor=eDP-1, $modeline, auto, 1/" "$configPath") + newConfigContent=$(sed "s/^monitor=.*$/monitor=eDP-1, $resolution@$rate, auto, 1/" "$configPath") echo "$newConfigContent" > "$configPath" } @@ -85,4 +96,4 @@ fi update_resolution_config "$newWidth" "$newHeight" "$newRefreshRate" -echo "Resolution updated successfully." \ No newline at end of file +echo "Resolution updated successfully."