diff --git a/.scripts/issu.sh b/.scripts/issu.sh index d1080a5..d66a330 100755 --- a/.scripts/issu.sh +++ b/.scripts/issu.sh @@ -1,21 +1,23 @@ #!/bin/sh if [ "$(id -u)" -eq 0 ]; then - exit 1 + exit 0 fi if [ -n "$SUDO_USER" ]; then - exit 1 + exit 0 fi if [ "$LOGNAME" != "$USER" ]; then - exit 1 + exit 0 fi ppid=$(ps -o ppid= -p $$ 2>/dev/null) if [ -n "$ppid" ]; then parent_comm=$(ps -o comm= -p "$ppid" 2>/dev/null) if [ "$parent_comm" = "su" ]; then - exit 1 + exit 0 fi fi + +exit 1 \ No newline at end of file diff --git a/.scripts/smb-mount.sh b/.scripts/smb-mount.sh index 171a963..cc29157 100755 --- a/.scripts/smb-mount.sh +++ b/.scripts/smb-mount.sh @@ -2,7 +2,7 @@ path="$(dirname "$(realpath "$0")")" -"$path/issu.sh" || { +"$path/issu.sh" && { echo "Do not run this script in sudo mode." exit 1 } diff --git a/.scripts/waybar-toggle.sh b/.scripts/waybar-toggle.sh index e2385b6..71b87b0 100755 --- a/.scripts/waybar-toggle.sh +++ b/.scripts/waybar-toggle.sh @@ -1,10 +1,4 @@ #!/bin/env bash -### - # @Author: Uyanide pywang0608@foxmail.com - # @Date: 2025-07-27 22:37:59 - # @LastEditTime: 2025-08-03 00:34:03 - # @Description: Toggle Waybar and close the lyrics widget if open -### function close() { killall -q waybar diff --git a/.scripts/wsl-mount.sh b/.scripts/wsl-mount.sh index ff26c82..249291c 100755 --- a/.scripts/wsl-mount.sh +++ b/.scripts/wsl-mount.sh @@ -2,7 +2,7 @@ path="$(dirname "$(realpath "$0")")" -"$path/issu.sh" || { +"$path/issu.sh" && { echo "Do not run this script in sudo mode." exit 1 } @@ -21,6 +21,12 @@ sudo chown "$username:$username" "$mount_point" export LIBGUESTFS_BACKEND=direct +# replay log +# qemu-img check -r all "$VHDX_PATH" || { +# echo "Failed to check VHDX file." +# exit 1 +# } + guestmount --add "$vhdx_path" --inspector --ro "$mount_point" || { echo "Failed to mount VHDX file." exit 1 diff --git a/waybar/config.jsonc b/waybar/config.jsonc index 2242384..24150ac 100644 --- a/waybar/config.jsonc +++ b/waybar/config.jsonc @@ -10,7 +10,7 @@ "spacing": 2, // Gaps between modules (px) "modules-left": ["custom/rofi", "group/workspaceactions", "hyprland/window", "custom/mediaplayer"], "modules-center": ["clock"], - "modules-right": ["group/monitors", "tray", "custom/caffeine", "custom/power"], + "modules-right": ["group/monitors", "tray", "idle_inhibitor", "custom/power"], // ------------------------------------------------------------------------- // Modules // ------------------------------------------------------------------------- @@ -33,20 +33,14 @@ "min-length": 2, "max-length": 2 }, - "custom/caffeine": { + "idle_inhibitor": { "format": "{icon}", - "return-type": "json", - "interval": "once", - "exec": "$HOME/.config/waybar/modules/caffeine.sh", - "on-click": "$HOME/.config/waybar/modules/caffeine.sh toggle && sleep 0.2", - "exec-on-event": true, - "min-length": 2, - "max-length": 2, - "tooltip": false, "format-icons": { - "active": "", - "inactive": "" - } + "activated": "", + "deactivated": "" + }, + "min-length": 2, + "max-length": 2 }, // Time and Date "clock": { diff --git a/waybar/modules/caffeine.sh b/waybar/modules/caffeine.sh deleted file mode 100755 index 76661f3..0000000 --- a/waybar/modules/caffeine.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/env bash - -function output() { - jq -n --unbuffered --compact-output \ - --arg alt "$1" \ - --arg class "$2" \ - '{alt: $alt, class: [$class]}' -} - -if [ -n "$1" ]; then - pid=$(pgrep -x "hypridle") - if [ -n "$pid" ]; then - killall hypridle > /dev/null 2>&1 - notify-send "Caffeine enabled" "POWERRR!!!" - else - hyprctl dispatch exec hypridle > /dev/null 2>&1 - notify-send "Caffeine disabled" "zzz..." - fi - exit 0 -fi - -# sleep 0.2 # Allow hypridle to start -pid=$(pgrep -x "hypridle") -if [ -n "$pid" ]; then - output "inactive" "inactive" -else - output "active" "active" -fi \ No newline at end of file diff --git a/waybar/modules/mail.py b/waybar/modules/mail.py deleted file mode 100755 index abc36ec..0000000 --- a/waybar/modules/mail.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/python - -import os -import imaplib - -import mailsecrets - -def getmails(username, password, server): - imap = imaplib.IMAP4_SSL(server, 993) - imap.login(username, password) - imap.select('INBOX') - ustatus, uresponse = imap.uid('search', None, 'UNSEEN') - if ustatus == 'OK': - unread_msg_nums = uresponse[0].split() - else: - unread_msg_nums = [] - - fstatus, fresponse = imap.uid('search', None, 'FLAGGED') - if fstatus == 'OK': - flagged_msg_nums = fresponse[0].split() - else: - flagged_msg_nums = [] - - return [len(unread_msg_nums), len(flagged_msg_nums)] - -ping = os.system("ping " + mailsecrets.server + " -c1 > /dev/null 2>&1") -if ping == 0: - mails = getmails(mailsecrets.username, mailsecrets.password, mailsecrets.server) - text = '' - alt = '' - - if mails[0] > 0: - text = alt = str(mails[0]) - if mails[1] > 0: - alt = str(mails[1]) + "  " + alt - else: - exit(1) - - print('{"text":"' + text + '", "alt": "' + alt + '"}') - -else: - exit(1) diff --git a/waybar/modules/spotify.sh b/waybar/modules/spotify.sh deleted file mode 100755 index c00622b..0000000 --- a/waybar/modules/spotify.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -class=$(playerctl metadata --player=spotify --format '{{lc(status)}}') -icon="" - -if [[ $class == "playing" ]]; then - info=$(playerctl metadata --player=spotify --format '{{artist}} - {{title}}') - if [[ ${#info} > 40 ]]; then - info=$(echo $info | cut -c1-40)"..." - fi - text=$info" "$icon -elif [[ $class == "paused" ]]; then - text=$icon -elif [[ $class == "stopped" ]]; then - text="" -fi - -echo -e "{\"text\":\""$text"\", \"class\":\""$class"\"}" diff --git a/waybar/modules/storage.sh b/waybar/modules/storage.sh deleted file mode 100755 index ae2a5ce..0000000 --- a/waybar/modules/storage.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -mount="/" -warning=20 -critical=10 - -df -h -P -l "$mount" | awk -v warning=$warning -v critical=$critical ' -/\/.*/ { - text=$4 - tooltip="Filesystem: "$1"\rSize: "$2"\rUsed: "$3"\rAvail: "$4"\rUse%: "$5"\rMounted on: "$6 - use=$5 - exit 0 -} -END { - class="" - gsub(/%$/,"",use) - if ((100 - use) < critical) { - class="critical" - } else if ((100 - use) < warning) { - class="warning" - } - print "{\"text\":\""text"\", \"percentage\":"use",\"tooltip\":\""tooltip"\", \"class\":\""class"\"}" -} -' diff --git a/waybar/modules/weather.sh b/waybar/modules/weather.sh deleted file mode 100755 index 06157ef..0000000 --- a/waybar/modules/weather.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash - -cachedir=~/.cache/rbn -cachefile=${0##*/}-$1 - -if [ ! -d $cachedir ]; then - mkdir -p $cachedir -fi - -if [ ! -f $cachedir/$cachefile ]; then - touch $cachedir/$cachefile -fi - -# Save current IFS -SAVEIFS=$IFS -# Change IFS to new line. -IFS=$'\n' - -cacheage=$(($(date +%s) - $(stat -c '%Y' "$cachedir/$cachefile"))) -if [ $cacheage -gt 1740 ] || [ ! -s $cachedir/$cachefile ]; then - data=($(curl -s https://en.wttr.in/$1\?0qnT 2>&1)) - echo ${data[0]} | cut -f1 -d, > $cachedir/$cachefile - echo ${data[1]} | sed -E 's/^.{15}//' >> $cachedir/$cachefile - echo ${data[2]} | sed -E 's/^.{15}//' >> $cachedir/$cachefile -fi - -weather=($(cat $cachedir/$cachefile)) - -# Restore IFSClear -IFS=$SAVEIFS - -temperature=$(echo ${weather[2]} | sed -E 's/([[:digit:]])+\.\./\1 to /g') - -#echo ${weather[1]##*,} - -# https://fontawesome.com/icons?s=solid&c=weather -case $(echo ${weather[1]##*,} | tr '[:upper:]' '[:lower:]') in -"clear" | "sunny") - condition="" - ;; -"partly cloudy") - condition="杖" - ;; -"cloudy") - condition="" - ;; -"overcast") - condition="" - ;; -"mist" | "fog" | "freezing fog") - condition="" - ;; -"patchy rain possible" | "patchy light drizzle" | "light drizzle" | "patchy light rain" | "light rain" | "light rain shower" | "rain") - condition="" - ;; -"moderate rain at times" | "moderate rain" | "heavy rain at times" | "heavy rain" | "moderate or heavy rain shower" | "torrential rain shower" | "rain shower") - condition="" - ;; -"patchy snow possible" | "patchy sleet possible" | "patchy freezing drizzle possible" | "freezing drizzle" | "heavy freezing drizzle" | "light freezing rain" | "moderate or heavy freezing rain" | "light sleet" | "ice pellets" | "light sleet showers" | "moderate or heavy sleet showers") - condition="ﭽ" - ;; -"blowing snow" | "moderate or heavy sleet" | "patchy light snow" | "light snow" | "light snow showers") - condition="流" - ;; -"blizzard" | "patchy moderate snow" | "moderate snow" | "patchy heavy snow" | "heavy snow" | "moderate or heavy snow with thunder" | "moderate or heavy snow showers") - condition="ﰕ" - ;; -"thundery outbreaks possible" | "patchy light rain with thunder" | "moderate or heavy rain with thunder" | "patchy light snow with thunder") - condition="" - ;; -*) - condition="" - echo -e "{\"text\":\""$condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}" - ;; -esac - -#echo $temp $condition - -echo -e "{\"text\":\""$temperature $condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}" diff --git a/waybar/style.css b/waybar/style.css index 3088fcc..3c59447 100644 --- a/waybar/style.css +++ b/waybar/style.css @@ -43,7 +43,7 @@ tooltip { #custom-power-menu, #tray, #custom-rofi, -#custom-caffeine, +#idle_inhibitor, #custom-power { background-color: alpha(@base, 0.6); border-radius: 14px; @@ -51,7 +51,7 @@ tooltip { } #custom-rofi, -#custom-caffeine, +#idle_inhibitor, #custom-power { padding-left: 6px; padding-right: 6px; @@ -96,7 +96,7 @@ tooltip { transition: none; /* Disable background transition */ } -window#waybar.empty #window{ +window#waybar.empty #window { background-color: transparent; padding: 0; margin: 0; @@ -165,15 +165,15 @@ window#waybar.empty #window{ background-color: alpha(@archlinux, 0.3); } -#custom-caffeine { +#idle_inhibitor { border: 3px solid @yellow; } -#custom-caffeine:hover { +#idle_inhibitor:hover { background-color: alpha(@yellow, 0.3); } -#custom-caffeine.active { +#idle_inhibitor.activated { border: 3px solid @peach; } @@ -211,4 +211,4 @@ window#waybar.empty #window{ #tray > .needs-attention { -gtk-icon-effect: highlight; background-color: #eb4d4b; -} \ No newline at end of file +}