waybar: use idle_inhibitor instead of custom module
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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
|
||||
@@ -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)
|
||||
@@ -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"\"}"
|
||||
@@ -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"\"}"
|
||||
}
|
||||
'
|
||||
@@ -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]}"\"}"
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user