From 6c96baddd16accffb27cad48d534cf688e83d332 Mon Sep 17 00:00:00 2001 From: brockar Date: Fri, 21 Feb 2025 16:32:04 -0300 Subject: Weather.py update, auto get location I just can test it on my location, so I need that be tested before merging :) --- config/hypr/UserScripts/Weather.py | 61 +++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 33 deletions(-) (limited to 'config/hypr/UserScripts/Weather.py') diff --git a/config/hypr/UserScripts/Weather.py b/config/hypr/UserScripts/Weather.py index e3a6c538..c739d2c5 100755 --- a/config/hypr/UserScripts/Weather.py +++ b/config/hypr/UserScripts/Weather.py @@ -1,13 +1,22 @@ #!/usr/bin/env python3 # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ # +# original code https://gist.github.com/Surendrajat/ff3876fd2166dd86fb71180f4e9342d7 # weather using python -import subprocess -from pyquery import PyQuery # install using `pip install pyquery` +import requests import json import os +from pyquery import PyQuery # install using `pip install pyquery` + + +# Get current location based on IP address +def get_location(): + response = requests.get("https://ipinfo.io") + data = response.json() + loc = data["loc"].split(",") + return float(loc[0]), float(loc[1]) + -# original code https://gist.github.com/Surendrajat/ff3876fd2166dd86fb71180f4e9342d7 # weather icons weather_icons = { "sunnyDay": "󰖙", @@ -22,30 +31,22 @@ weather_icons = { "default": "", } -# get location_id -# to get your own location_id, go to https://weather.com & search your location. -# once you choose your location, you can see the location_id in the URL(64 chars long hex string) -# like this: https://weather.com/en-PH/weather/today/l/bca47d1099e762a012b9a139c36f30a0b1e647f69c0c4ac28b537e7ae9c1c200 -location_id = "bca47d1099e762a012b9a139c36f30a0b1e647f69c0c4ac28b537e7ae9c1c200" # TODO +# Get latitude and longitude +latitude, longitude = get_location() -# NOTE to change to deg F, change the URL to your preffered location after weather.com -# Default is English-Philippines with Busan, South Korea as location_id -# get html page -url = "https://weather.com/en-PH/weather/today/l/" + location_id +# Open-Meteo API endpoint +url = f"https://weather.com/en-PH/weather/today/l/{latitude},{longitude}" html_data = PyQuery(url=url) # current temperature temp = html_data("span[data-testid='TemperatureValue']").eq(0).text() -# print(temp) # current status phrase status = html_data("div[data-testid='wxPhrase']").text() status = f"{status[:16]}.." if len(status) > 17 else status -# print(status) # status code status_code = html_data("#regionHeader").attr("class").split(" ")[2].split("-")[2] -# print(status_code) # status icon icon = ( @@ -53,14 +54,12 @@ icon = ( if status_code in weather_icons else weather_icons["default"] ) -# print(icon) # temperature feels like temp_feel = html_data( "div[data-testid='FeelsLikeSection'] > span > span[data-testid='TemperatureValue']" ).text() temp_feel_text = f"Feels like {temp_feel}c" -# print(temp_feel_text) # min-max temperature temp_min = ( @@ -74,26 +73,21 @@ temp_max = ( .text() ) temp_min_max = f" {temp_min}\t\t {temp_max}" -# print(temp_min_max) # wind speed wind_speed = html_data("span[data-testid='Wind']").text().split("\n")[1] wind_text = f" {wind_speed}" -# print(wind_text) # humidity humidity = html_data("span[data-testid='PercentageValue']").text() humidity_text = f" {humidity}" -# print(humidity_text) # visibility -visbility = html_data("span[data-testid='VisibilityValue']").text() -visbility_text = f" {visbility}" -# print(visbility_text) +visibility = html_data("span[data-testid='VisibilityValue']").text() +visibility_text = f" {visibility}" # air quality index air_quality_index = html_data("text[data-testid='DonutChartValue']").text() -# print(air_quality_index) # hourly rain prediction prediction = html_data("section[aria-label='Hourly Forecast']")( @@ -101,7 +95,6 @@ prediction = html_data("section[aria-label='Hourly Forecast']")( ).text() prediction = prediction.replace("Chance of Rain", "") prediction = f"\n\n (hourly) {prediction}" if len(prediction) > 0 else prediction -# print(prediction) # tooltip text tooltip_text = str.format( @@ -112,7 +105,7 @@ tooltip_text = str.format( f"{temp_feel_text}", f"{temp_min_max}", f"{wind_text}\t{humidity_text}", - f"{visbility_text}\tAQI {air_quality_index}", + f"{visibility_text}\tAQI {air_quality_index}", f" {prediction}", ) @@ -125,14 +118,16 @@ out_data = { } print(json.dumps(out_data)) -simple_weather =f"{icon} {status}\n" + \ - f" {temp} ({temp_feel_text})\n" + \ - f"{wind_text} \n" + \ - f"{humidity_text} \n" + \ - f"{visbility_text} AQI{air_quality_index}\n" +simple_weather = ( + f"{icon} {status}\n" + + f" {temp} ({temp_feel_text})\n" + + f"{wind_text} \n" + + f"{humidity_text} \n" + + f"{visibility_text} AQI{air_quality_index}\n" +) try: with open(os.path.expanduser("~/.cache/.weather_cache"), "w") as file: file.write(simple_weather) -except: - pass +except Exception as e: + print(f"Error writing to cache: {e}") -- cgit v1.2.3 From 341cdff88a33007724b59018d486363eda4c22c9 Mon Sep 17 00:00:00 2001 From: "Ja.KooLit" <85185940+JaKooLit@users.noreply.github.com> Date: Sat, 22 Feb 2025 10:22:19 +0900 Subject: Update Weather.py just added the manual addition of location in case user wants that --- config/hypr/UserScripts/Weather.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'config/hypr/UserScripts/Weather.py') diff --git a/config/hypr/UserScripts/Weather.py b/config/hypr/UserScripts/Weather.py index c739d2c5..b9efe4e4 100755 --- a/config/hypr/UserScripts/Weather.py +++ b/config/hypr/UserScripts/Weather.py @@ -8,15 +8,6 @@ import json import os from pyquery import PyQuery # install using `pip install pyquery` - -# Get current location based on IP address -def get_location(): - response = requests.get("https://ipinfo.io") - data = response.json() - loc = data["loc"].split(",") - return float(loc[0]), float(loc[1]) - - # weather icons weather_icons = { "sunnyDay": "󰖙", @@ -31,11 +22,31 @@ weather_icons = { "default": "", } +# Get current location based on IP address +def get_location(): + response = requests.get("https://ipinfo.io") + data = response.json() + loc = data["loc"].split(",") + return float(loc[0]), float(loc[1]) + # Get latitude and longitude latitude, longitude = get_location() # Open-Meteo API endpoint url = f"https://weather.com/en-PH/weather/today/l/{latitude},{longitude}" + +# manual location_id +# NOTE: if you want to add manually, make sure you disable def get_location above +# to get your own location_id, go to https://weather.com & search your location. +# once you choose your location, you can see the location_id in the URL(64 chars long hex string) +# like this: https://weather.com/en-PH/weather/today/l/bca47d1099e762a012b9a139c36f30a0b1e647f69c0c4ac28b537e7ae9c1c200 +#location_id = "bca47d1099e762a012b9a139c36f30a0b1e647f69c0c4ac28b537e7ae9c1c200" # TODO + +# NOTE to change to deg F, change the URL to your preffered location after weather.com +# Default is English-Philippines with Busan, South Korea as location_id +# get html page +#url = "https://weather.com/en-PH/weather/today/l/" + location_id + html_data = PyQuery(url=url) # current temperature -- cgit v1.2.3 From 9df8836dc8bf17a86990bbf659105626138552cb Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Sun, 23 Feb 2025 13:15:07 +0900 Subject: Not sure if important.. but whatever --- README.md | 2 +- config/hypr/UserScripts/Kool_Quick_Settings.sh | 2 +- config/hypr/UserScripts/RofiBeats.sh | 4 +-- config/hypr/UserScripts/WallpaperEffects.sh | 2 +- config/hypr/UserScripts/WallpaperSelect.sh | 2 +- config/hypr/UserScripts/Weather.py | 2 +- config/hypr/UserScripts/Weather.sh | 4 +-- config/hypr/UserScripts/ZshChangeTheme.sh | 2 +- config/hypr/hyprlock-1080p.conf | 2 +- config/hypr/hyprlock.conf | 2 +- config/hypr/initial-boot.sh | 4 +-- config/hypr/scripts/Animations.sh | 2 +- config/hypr/scripts/ClipManager.sh | 2 +- config/hypr/scripts/DarkLight.sh | 2 +- config/hypr/scripts/MonitorProfiles.sh | 4 +-- config/hypr/scripts/RofiEmoji.sh | 2 +- config/waybar/configs/[TOP] Everforest | 4 +-- copy.sh | 43 +++++++++++++------------- upgrade.sh | 10 +++--- 19 files changed, 49 insertions(+), 48 deletions(-) (limited to 'config/hypr/UserScripts/Weather.py') diff --git a/README.md b/README.md index b6858135..58f5e712 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ chmod +x upgrade.sh ## ⚠️⚠️⚠️ ATTENTION - BACKUPS CREATED by SCRIPT > [!CAUTION] > copy.sh, release.sh and even upgrade.sh creates a backup! -> Kindly investigate manually contents on your ~/.config +> Kindly investigate manually contents on your $HOME/.config > Delete manually all the backups which you dont need #### 🛎️ a small note on wallpapers diff --git a/config/hypr/UserScripts/Kool_Quick_Settings.sh b/config/hypr/UserScripts/Kool_Quick_Settings.sh index a6dc2885..88e26089 100755 --- a/config/hypr/UserScripts/Kool_Quick_Settings.sh +++ b/config/hypr/UserScripts/Kool_Quick_Settings.sh @@ -9,7 +9,7 @@ tty=kitty # variables configs="$HOME/.config/hypr/configs" UserConfigs="$HOME/.config/hypr/UserConfigs" -rofi_theme="~/.config/rofi/config-edit.rasi" +rofi_theme="$HOME/.config/rofi/config-edit.rasi" msg=' ⁉️ Choose what to do ⁉️' iDIR="$HOME/.config/swaync/images" scriptsDir="$HOME/.config/hypr/scripts" diff --git a/config/hypr/UserScripts/RofiBeats.sh b/config/hypr/UserScripts/RofiBeats.sh index 74a8fe54..4587e720 100755 --- a/config/hypr/UserScripts/RofiBeats.sh +++ b/config/hypr/UserScripts/RofiBeats.sh @@ -5,8 +5,8 @@ # Variables mDIR="$HOME/Music/" iDIR="$HOME/.config/swaync/icons" -rofi_theme="~/.config/rofi/config-rofi-Beats.rasi" -rofi_theme_1="~/.config/rofi/config-rofi-Beats-menu.rasi" +rofi_theme="$HOME/.config/rofi/config-rofi-Beats.rasi" +rofi_theme_1="$HOME/.config/rofi/config-rofi-Beats-menu.rasi" # Online Stations. Edit as required declare -A online_music=( diff --git a/config/hypr/UserScripts/WallpaperEffects.sh b/config/hypr/UserScripts/WallpaperEffects.sh index c98400d2..948c637c 100755 --- a/config/hypr/UserScripts/WallpaperEffects.sh +++ b/config/hypr/UserScripts/WallpaperEffects.sh @@ -8,7 +8,7 @@ wallpaper_current="$HOME/.config/hypr/wallpaper_effects/.wallpaper_current" wallpaper_output="$HOME/.config/hypr/wallpaper_effects/.wallpaper_modified" SCRIPTSDIR="$HOME/.config/hypr/scripts" focused_monitor=$(hyprctl monitors -j | jq -r '.[] | select(.focused) | .name') -rofi_theme="~/.config/rofi/config-wallpaper-effect.rasi" +rofi_theme="$HOME/.config/rofi/config-wallpaper-effect.rasi" # Directory for swaync iDIR="$HOME/.config/swaync/images" diff --git a/config/hypr/UserScripts/WallpaperSelect.sh b/config/hypr/UserScripts/WallpaperSelect.sh index 86b7dfa2..78bf8d2f 100755 --- a/config/hypr/UserScripts/WallpaperSelect.sh +++ b/config/hypr/UserScripts/WallpaperSelect.sh @@ -15,7 +15,7 @@ iDIR="$HOME/.config/swaync/images" iDIRi="$HOME/.config/swaync/icons" # variables -rofi_theme="~/.config/rofi/config-wallpaper.rasi" +rofi_theme="$HOME/.config/rofi/config-wallpaper.rasi" focused_monitor=$(hyprctl monitors -j | jq -r '.[] | select(.focused) | .name') # Get monitor width and DPI diff --git a/config/hypr/UserScripts/Weather.py b/config/hypr/UserScripts/Weather.py index b9efe4e4..a2ad98b5 100755 --- a/config/hypr/UserScripts/Weather.py +++ b/config/hypr/UserScripts/Weather.py @@ -138,7 +138,7 @@ simple_weather = ( ) try: - with open(os.path.expanduser("~/.cache/.weather_cache"), "w") as file: + with open(os.path.expanduser("$HOME/.cache/.weather_cache"), "w") as file: file.write(simple_weather) except Exception as e: print(f"Error writing to cache: {e}") diff --git a/config/hypr/UserScripts/Weather.sh b/config/hypr/UserScripts/Weather.sh index 65613fca..9bdaff4a 100755 --- a/config/hypr/UserScripts/Weather.sh +++ b/config/hypr/UserScripts/Weather.sh @@ -4,7 +4,7 @@ # Remember to add city city= -cachedir=~/.cache/rbn +cachedir="$HOME/.cache/rbn" cachefile=${0##*/}-$1 if [ ! -d $cachedir ]; then @@ -84,4 +84,4 @@ echo -e "{\"text\":\""$temperature $condition"\", \"alt\":\""${weather[0]}"\", \ cached_weather=" $temperature \n$condition ${weather[1]}" -echo -e $cached_weather > ~/.cache/.weather_cache \ No newline at end of file +echo -e $cached_weather > "$HOME/.cache/.weather_cache" \ No newline at end of file diff --git a/config/hypr/UserScripts/ZshChangeTheme.sh b/config/hypr/UserScripts/ZshChangeTheme.sh index 4ff43557..fafd7fb0 100755 --- a/config/hypr/UserScripts/ZshChangeTheme.sh +++ b/config/hypr/UserScripts/ZshChangeTheme.sh @@ -10,7 +10,7 @@ file_extension=".zsh-theme" # Variables iDIR="$HOME/.config/swaync/images" -rofi_theme="~/.config/rofi/config-zsh-theme.rasi" +rofi_theme="$HOME/.config/rofi/config-zsh-theme.rasi" themes_array=($(find -L "$themes_dir" -type f -name "*$file_extension" -exec basename {} \; | sed -e "s/$file_extension//")) diff --git a/config/hypr/hyprlock-1080p.conf b/config/hypr/hyprlock-1080p.conf index acd3258c..9fcac975 100644 --- a/config/hypr/hyprlock-1080p.conf +++ b/config/hypr/hyprlock-1080p.conf @@ -153,7 +153,7 @@ label { # see https://github.com/JaKooLit/Hyprland-Dots/wiki/TIPS#%EF%B8%8F-weather-app-related-for-waybar-and-hyprlock label { monitor = - text = cmd[update:3600000] [ -f ~/.cache/.weather_cache ] && cat ~/.cache/.weather_cache + text = cmd[update:3600000] [ -f "$HOME/.cache/.weather_cache" ] && cat "$HOME/.cache/.weather_cache" color = $color13 font_size = 16 font_family = Victor Mono Bold Oblique diff --git a/config/hypr/hyprlock.conf b/config/hypr/hyprlock.conf index 9edb3088..bfeda4ab 100644 --- a/config/hypr/hyprlock.conf +++ b/config/hypr/hyprlock.conf @@ -153,7 +153,7 @@ label { # see https://github.com/JaKooLit/Hyprland-Dots/wiki/TIPS#%EF%B8%8F-weather-app-related-for-waybar-and-hyprlock label { monitor = - text = cmd[update:3600000] [ -f ~/.cache/.weather_cache ] && cat ~/.cache/.weather_cache + text = cmd[update:3600000] [ -f "$HOME/.cache/.weather_cache" ] && cat "$HOME/.cache/.weather_cache" color = $color13 font_size = 18 font_family = Victor Mono Bold Oblique diff --git a/config/hypr/initial-boot.sh b/config/hypr/initial-boot.sh index 4d62775d..7f92ce7d 100755 --- a/config/hypr/initial-boot.sh +++ b/config/hypr/initial-boot.sh @@ -21,7 +21,7 @@ swww="swww img" effect="--transition-bezier .43,1.19,1,.4 --transition-fps 30 --transition-type grow --transition-pos 0.925,0.977 --transition-duration 2" # Check if a marker file exists. -if [ ! -f ~/.config/hypr/.initial_startup_done ]; then +if [ ! -f "$HOME/.config/hypr/.initial_startup_done" ]; then sleep 1 # Initialize wallust and wallpaper if [ -f "$wallpaper" ]; then @@ -60,7 +60,7 @@ if [ ! -f ~/.config/hypr/.initial_startup_done ]; then # Create a marker file to indicate that the script has been executed. - touch ~/.config/hypr/.initial_startup_done + touch "$HOME/.config/hypr/.initial_startup_done" exit fi diff --git a/config/hypr/scripts/Animations.sh b/config/hypr/scripts/Animations.sh index 4f49d47a..477e5cd3 100755 --- a/config/hypr/scripts/Animations.sh +++ b/config/hypr/scripts/Animations.sh @@ -12,7 +12,7 @@ iDIR="$HOME/.config/swaync/images" SCRIPTSDIR="$HOME/.config/hypr/scripts" animations_dir="$HOME/.config/hypr/animations" UserConfigs="$HOME/.config/hypr/UserConfigs" -rofi_theme="~/.config/rofi/config-Animations.rasi" +rofi_theme="$HOME/.config/rofi/config-Animations.rasi" msg='❗NOTE:❗ This will copy animations into UserAnimations.conf' # list of animation files, sorted alphabetically with numbers first animations_list=$(find -L "$animations_dir" -maxdepth 1 -type f | sed 's/.*\///' | sed 's/\.conf$//' | sort -V) diff --git a/config/hypr/scripts/ClipManager.sh b/config/hypr/scripts/ClipManager.sh index 1f82c616..9937b6f4 100755 --- a/config/hypr/scripts/ClipManager.sh +++ b/config/hypr/scripts/ClipManager.sh @@ -3,7 +3,7 @@ # Clipboard Manager. This script uses cliphist, rofi, and wl-copy. # Variables -rofi_theme="~/.config/rofi/config-clipboard.rasi" +rofi_theme="$HOME/.config/rofi/config-clipboard.rasi" msg='👀 **note** CTRL DEL = cliphist del (entry) or ALT DEL - cliphist wipe (all)' # Actions: # CTRL Del to delete an entry diff --git a/config/hypr/scripts/DarkLight.sh b/config/hypr/scripts/DarkLight.sh index 662e1954..6ce1526e 100755 --- a/config/hypr/scripts/DarkLight.sh +++ b/config/hypr/scripts/DarkLight.sh @@ -46,7 +46,7 @@ fi # Function to update theme mode for the next cycle update_theme_mode() { - echo "$next_mode" > ~/.cache/.theme_mode + echo "$next_mode" > "$HOME/.cache/.theme_mode" } # Function to notify user diff --git a/config/hypr/scripts/MonitorProfiles.sh b/config/hypr/scripts/MonitorProfiles.sh index ebab0144..ab124335 100755 --- a/config/hypr/scripts/MonitorProfiles.sh +++ b/config/hypr/scripts/MonitorProfiles.sh @@ -12,8 +12,8 @@ iDIR="$HOME/.config/swaync/images" SCRIPTSDIR="$HOME/.config/hypr/scripts" monitor_dir="$HOME/.config/hypr/Monitor_Profiles" target="$HOME/.config/hypr/monitors.conf" -rofi_theme="~/.config/rofi/config-Monitors.rasi" -msg='❗NOTE:❗ This will overwrite ~/.config/hypr/monitors.conf' +rofi_theme="$HOME/.config/rofi/config-Monitors.rasi" +msg='❗NOTE:❗ This will overwrite $HOME/.config/hypr/monitors.conf' # Define the list of files to ignore ignore_files=( diff --git a/config/hypr/scripts/RofiEmoji.sh b/config/hypr/scripts/RofiEmoji.sh index 3d85d6a3..da9da61f 100755 --- a/config/hypr/scripts/RofiEmoji.sh +++ b/config/hypr/scripts/RofiEmoji.sh @@ -2,7 +2,7 @@ # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## # Variables -rofi_theme="~/.config/rofi/config-emoji.rasi" +rofi_theme="$HOME/.config/rofi/config-emoji.rasi" msg='** note ** 👀 Click or Return to choose || Ctrl V to Paste' # Check if rofi is already running diff --git a/config/waybar/configs/[TOP] Everforest b/config/waybar/configs/[TOP] Everforest index 6663425b..9d2786c6 100644 --- a/config/waybar/configs/[TOP] Everforest +++ b/config/waybar/configs/[TOP] Everforest @@ -89,8 +89,8 @@ "format-time": "{H}h {M}min", "tooltip": true, "tooltip-format": "{timeTo} {power}w", - "on-click-middle": "~/.config/hypr/scripts/ChangeBlur.sh", - "on-click-right": "~/.config/hypr/scripts/Wlogout.sh", + "on-click-middle": "$HOME/.config/hypr/scripts/ChangeBlur.sh", + "on-click-right": "$HOME/.config/hypr/scripts/Wlogout.sh", }, "cpu#forest": { diff --git a/copy.sh b/copy.sh index ed6cd8b3..5d0013db 100755 --- a/copy.sh +++ b/copy.sh @@ -64,9 +64,10 @@ printf "\n%.0s" {1..1} ####### Announcement echo "${WARNING}A T T E N T I O N !${RESET}" -echo "${SKY_BLUE}This version (v2.3.12) requires nwg-displays!${RESET}" +echo "${SKY_BLUE}This version (v2.3.12) requires nwg-displays and some fonts!${RESET}" +echo "${SKY_BLUE}If you ran through (Distro-Hyprland install scripts), no need to do anything${RESET}" echo "${YELLOW}previous version: Some Keybinds changes${RESET}" -echo "${MAGENTA}Kindly visit KooL Hyprland Own Wiki for the changelog${RESET}" +echo "${MAGENTA}Kindly visit KooL Hyprland Own Wiki for changelogs${RESET}" printf "\n%.0s" {1..1} # Create Directory for Copy Logs @@ -458,8 +459,8 @@ get_backup_dirname() { # Check if the ~/.config/ directory exists if [ ! -d "$HOME/.config" ]; then - echo "${ERROR} - The ~/.config directory does not exist." - exit 1 + echo "${ERROR} - $HOME/.config directory does not exist. Creating it now." + mkdir -p "$HOME/.config" && echo "Directory created successfully." || echo "Failed to create directory." fi printf "${INFO} - copying dotfiles ${SKY_BLUE}first${RESET} part\n" @@ -563,7 +564,7 @@ fi DIR="btop cava hypr Kvantum qt5ct qt6ct swappy wallust wlogout" for DIR_NAME in $DIR; do - DIRPATH=~/.config/"$DIR_NAME" + DIRPATH="$HOME/.config/$DIR_NAME" # Backup the existing directory if it exists if [ -d "$DIRPATH" ]; then @@ -582,7 +583,7 @@ for DIR_NAME in $DIR; do # Copy the new config if [ -d "config/$DIR_NAME" ]; then - cp -r "config/$DIR_NAME/" ~/.config/"$DIR_NAME" 2>&1 | tee -a "$LOG" + cp -r "config/$DIR_NAME/" "$HOME/.config/$DIR_NAME" 2>&1 | tee -a "$LOG" if [ $? -eq 0 ]; then echo "${OK} - Copy of config for ${YELLOW}$DIR_NAME${RESET} completed!" else @@ -644,7 +645,7 @@ FILES_TO_RESTORE=( "WindowRules.conf" ) -DIRPATH=~/.config/"$DIRH" +DIRPATH="$HOME/.config/$DIRH" BACKUP_DIR=$(get_backup_dirname) BACKUP_DIR_PATH="$DIRPATH-backup-$BACKUP_DIR/UserConfigs" @@ -687,7 +688,7 @@ SCRIPTS_TO_RESTORE=( "Weather.sh" ) -DIRSHPATH=~/.config/"$DIRSH" +DIRSHPATH="$HOME/.config/$DIRSH" BACKUP_DIR_PATH_S="$DIRSHPATH-backup-$BACKUP_DIR/UserScripts" if [ -d "$BACKUP_DIR_PATH_S" ]; then @@ -721,12 +722,12 @@ FILES_2_RESTORE=( "hypridle.conf" ) -DIRPATH=~/.config/"$DIR_H" +DIRPATH="$HOME/.config/$DIR_H" BACKUP_DIR=$(get_backup_dirname) BACKUP_DIR_PATH_F="$DIRPATH-backup-$BACKUP_DIR" if [ -d "$BACKUP_DIR_PATH_F" ]; then - echo -e "${NOTE} Restoring some files in ${MAGENTA}~/.config/hypr directory${RESET}..." + echo -e "${NOTE} Restoring some files in ${MAGENTA}$HOME/.config/hypr directory${RESET}..." for FILE_RESTORE in "${FILES_2_RESTORE[@]}"; do BACKUP_FILE="$BACKUP_DIR_PATH_F/$FILE_RESTORE" @@ -762,7 +763,7 @@ if [ -d "$HOME/.config/rofi/themes" ]; then if [ -z "$(ls -A $HOME/.config/rofi/themes)" ]; then echo '/* Dummy Rofi theme */' > "$HOME/.config/rofi/themes/dummy.rasi" fi - ln -snf ~/.config/rofi/themes/* ~/.local/share/rofi/themes/ + ln -snf "$HOME/.config/rofi/themes/"* "$HOME/.local/share/rofi/themes/" # Delete the dummy file if it was created if [ -f "$HOME/.config/rofi/themes/dummy.rasi" ]; then rm "$HOME/.config/rofi/themes/dummy.rasi" @@ -772,18 +773,18 @@ fi printf "\n%.0s" {1..1} # wallpaper stuff -mkdir -p ~/Pictures/wallpapers -if cp -r wallpapers ~/Pictures/; then +mkdir -p $HOME/Pictures/wallpapers +if cp -r wallpapers $HOME/Pictures/; then echo "${OK} Some ${MAGENTA}wallpapers${RESET} copied successfully!" | tee -a "$LOG" else echo "${ERROR} Failed to copy some ${YELLOW}wallpapers${RESET}" | tee -a "$LOG" fi # Set some files as executable -chmod +x ~/.config/hypr/scripts/* 2>&1 | tee -a "$LOG" -chmod +x ~/.config/hypr/UserScripts/* 2>&1 | tee -a "$LOG" +chmod +x "$HOME/.config/hypr/scripts/"* 2>&1 | tee -a "$LOG" +chmod +x "$HOME/.config/hypr/UserScripts/"* 2>&1 | tee -a "$LOG" # Set executable for initial-boot.sh -chmod +x ~/.config/hypr/initial-boot.sh 2>&1 | tee -a "$LOG" +chmod +x "$HOME/.config/hypr/initial-boot.sh" 2>&1 | tee -a "$LOG" # Waybar config to symlink & retain based on machine type if hostnamectl | grep -q 'Chassis: desktop'; then @@ -850,12 +851,12 @@ while true; do echo "${OK} Wallpapers downloaded successfully." 2>&1 | tee -a "$LOG" # Check if wallpapers directory exists and create it if not - if [ ! -d ~/Pictures/wallpapers ]; then - mkdir -p ~/Pictures/wallpapers + if [ ! -d "$HOME/Pictures/wallpapers" ]; then + mkdir -p "$HOME/Pictures/wallpapers" echo "${OK} Created wallpapers directory." 2>&1 | tee -a "$LOG" fi - if cp -R Wallpaper-Bank/wallpapers/* ~/Pictures/wallpapers/ >> "$LOG" 2>&1; then + if cp -R Wallpaper-Bank/wallpapers/* "$HOME/Pictures/wallpapers/" >> "$LOG" 2>&1; then echo "${OK} Wallpapers copied successfully." 2>&1 | tee -a "$LOG" rm -rf Wallpaper-Bank 2>&1 # Remove cloned repository after copying wallpapers break @@ -878,10 +879,10 @@ done # CLeaning up of ~/.config/ backups cleanup_backups() { - CONFIG_DIR=~/.config + CONFIG_DIR="$HOME/.config" BACKUP_PREFIX="-backup" - # Loop through directories in ~/.config + # Loop through directories in $HOME/.config for DIR in "$CONFIG_DIR"/*; do if [ -d "$DIR" ]; then BACKUP_DIRS=() diff --git a/upgrade.sh b/upgrade.sh index 687ba69f..8c900f44 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -141,11 +141,11 @@ if version_gt "$latest_version" "$stored_version"; then printf "\n%.0s" {1..2} echo "$NOTE Files or Folders updated successfully to version $latest_version" 2>&1 | tee -a "$LOG" - # Set some files as executable - chmod +x ~/.config/hypr/scripts/* 2>&1 | tee -a "$LOG" - chmod +x ~/.config/hypr/UserScripts/* 2>&1 | tee -a "$LOG" - chmod +x ~/.config/hypr/initial-boot.sh 2>&1 | tee -a "$LOG" - + # Set some files as executable + chmod +x "$HOME/.config/hypr/scripts/"* 2>&1 | tee -a "$LOG" + chmod +x "$HOME/.config/hypr/UserScripts/"* 2>&1 | tee -a "$LOG" + # Set executable for initial-boot.sh + chmod +x "$HOME/.config/hypr/initial-boot.sh" 2>&1 | tee -a "$LOG" else echo "$MAGENTA Upgrade declined. No files or folders changed" 2>&1 | tee -a "$LOG" fi -- cgit v1.2.3