added quickshell and updated zsh
This commit is contained in:
66
home/hypr/quickshell/scripts/get_apps.sh
Executable file
66
home/hypr/quickshell/scripts/get_apps.sh
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
# Scans .desktop files and outputs JSON array of apps
|
||||
dirs=(
|
||||
"/run/current-system/sw/share/applications"
|
||||
"$HOME/.nix-profile/share/applications"
|
||||
"$HOME/.local/share/applications"
|
||||
"/usr/share/applications"
|
||||
)
|
||||
|
||||
declare -A seen
|
||||
apps="["
|
||||
first=true
|
||||
|
||||
# Add default curated Mac/system apps first
|
||||
curated=(
|
||||
'{"name":"Finder","exec":"foot -e sh -c \"cd ~; lf || yazi || ls -la; exec zsh\"","icon":"finder","comment":"File Manager"}'
|
||||
'{"name":"Terminal","exec":"foot","icon":"terminal","comment":"Command Line Interface"}'
|
||||
'{"name":"Brave Browser","exec":"brave","icon":"browser","comment":"Web Browser"}'
|
||||
'{"name":"Neovim","exec":"foot -e nvim","icon":"code","comment":"Text & Code Editor"}'
|
||||
'{"name":"System Preferences","exec":"pavucontrol","icon":"preferences","comment":"Audio & System Settings"}'
|
||||
'{"name":"Activity Monitor","exec":"foot -e btop","icon":"preferences","comment":"Resource Monitor"}'
|
||||
'{"name":"Lock Screen","exec":"hyprlock","icon":"preferences","comment":"Lock current session"}'
|
||||
'{"name":"Restart System","exec":"systemctl reboot","icon":"preferences","comment":"Reboot NixOS"}'
|
||||
'{"name":"Shut Down","exec":"systemctl poweroff","icon":"preferences","comment":"Power off computer"}'
|
||||
)
|
||||
|
||||
for app in "${curated[@]}"; do
|
||||
if [ "$first" = true ]; then
|
||||
apps="$apps$app"
|
||||
first=false
|
||||
else
|
||||
apps="$apps,$app"
|
||||
fi
|
||||
done
|
||||
|
||||
for dir in "${dirs[@]}"; do
|
||||
if [ -d "$dir" ]; then
|
||||
for f in "$dir"/*.desktop; do
|
||||
[ -e "$f" ] || continue
|
||||
# Check NoDisplay
|
||||
if grep -q "^NoDisplay=true" "$f" 2>/dev/null; then
|
||||
continue
|
||||
fi
|
||||
|
||||
name=$(grep -m 1 "^Name=" "$f" 2>/dev/null | cut -d= -f2- | tr -d '\r\n')
|
||||
exec_cmd=$(grep -m 1 "^Exec=" "$f" 2>/dev/null | cut -d= -f2- | sed -E 's/%[fFuUdDnNickvm]//g' | tr -d '\r\n')
|
||||
icon=$(grep -m 1 "^Icon=" "$f" 2>/dev/null | cut -d= -f2- | tr -d '\r\n')
|
||||
comment=$(grep -m 1 "^Comment=" "$f" 2>/dev/null | cut -d= -f2- | tr -d '\r\n')
|
||||
|
||||
if [ -n "$name" ] && [ -n "$exec_cmd" ] && [ -z "${seen[$name]}" ]; then
|
||||
seen[$name]=1
|
||||
# Escape quotes
|
||||
name_esc=$(echo "$name" | sed 's/"/\\"/g')
|
||||
exec_esc=$(echo "$exec_cmd" | sed 's/"/\\"/g')
|
||||
icon_esc=$(echo "$icon" | sed 's/"/\\"/g')
|
||||
comment_esc=$(echo "$comment" | sed 's/"/\\"/g')
|
||||
|
||||
entry="{\"name\":\"$name_esc\",\"exec\":\"$exec_esc\",\"icon\":\"$icon_esc\",\"comment\":\"$comment_esc\"}"
|
||||
apps="$apps,$entry"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
apps="$apps]"
|
||||
echo "$apps"
|
||||
20
home/hypr/quickshell/scripts/get_audio.sh
Executable file
20
home/hypr/quickshell/scripts/get_audio.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# Read audio volume & mute state
|
||||
volume=50
|
||||
muted=false
|
||||
|
||||
if command -v pactl &>/dev/null; then
|
||||
vol_str=$(pactl get-sink-volume @DEFAULT_SINK@ 2>/dev/null | grep -Po '[0-9]+(?=%)' | head -n 1)
|
||||
if [ -n "$vol_str" ]; then
|
||||
volume=$vol_str
|
||||
fi
|
||||
mute_str=$(pactl get-sink-mute @DEFAULT_SINK@ 2>/dev/null)
|
||||
if echo "$mute_str" | grep -q "yes"; then
|
||||
muted=true
|
||||
fi
|
||||
elif command -v pamixer &>/dev/null; then
|
||||
volume=$(pamixer --get-volume 2>/dev/null || echo 50)
|
||||
muted=$(pamixer --get-mute 2>/dev/null || echo false)
|
||||
fi
|
||||
|
||||
echo "{\"volume\": $volume, \"muted\": $muted}"
|
||||
16
home/hypr/quickshell/scripts/get_battery.sh
Executable file
16
home/hypr/quickshell/scripts/get_battery.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# Read battery state
|
||||
bat_path=$(find /sys/class/power_supply/ -name "BAT*" 2>/dev/null | head -n 1)
|
||||
|
||||
if [ -n "$bat_path" ] && [ -d "$bat_path" ]; then
|
||||
capacity=$(cat "$bat_path/capacity" 2>/dev/null || echo 100)
|
||||
status=$(cat "$bat_path/status" 2>/dev/null || echo "Full")
|
||||
is_charging=false
|
||||
if [ "$status" = "Charging" ] || [ "$status" = "Full" ]; then
|
||||
is_charging=true
|
||||
fi
|
||||
echo "{\"present\": true, \"percent\": $capacity, \"status\": \"$status\", \"charging\": $is_charging}"
|
||||
else
|
||||
# Desktop without battery
|
||||
echo "{\"present\": false, \"percent\": 100, \"status\": \"AC\", \"charging\": true}"
|
||||
fi
|
||||
12
home/hypr/quickshell/scripts/get_brightness.sh
Executable file
12
home/hypr/quickshell/scripts/get_brightness.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# Read brightness
|
||||
percent=100
|
||||
|
||||
if command -v brightnessctl &>/dev/null; then
|
||||
percent=$(brightnessctl -m 2>/dev/null | cut -d, -f4 | tr -d '%' | head -n 1)
|
||||
if [ -z "$percent" ]; then
|
||||
percent=100
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "{\"brightness\": ${percent:-100}}"
|
||||
20
home/hypr/quickshell/scripts/get_cpu.sh
Executable file
20
home/hypr/quickshell/scripts/get_cpu.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# Read /proc/stat CPU utilization
|
||||
read -r cpu u n s i io ir st g gn < /proc/stat
|
||||
total1=$((u + n + s + i + io + ir + st + g + gn))
|
||||
idle1=$((i + io))
|
||||
sleep 0.2
|
||||
read -r cpu u n s i io ir st g gn < /proc/stat
|
||||
total2=$((u + n + s + i + io + ir + st + g + gn))
|
||||
idle2=$((i + io))
|
||||
|
||||
total_diff=$((total2 - total1))
|
||||
idle_diff=$((idle2 - idle1))
|
||||
|
||||
if [ "$total_diff" -gt 0 ]; then
|
||||
cpu_usage=$(( (total_diff - idle_diff) * 100 / total_diff ))
|
||||
else
|
||||
cpu_usage=0
|
||||
fi
|
||||
|
||||
echo "$cpu_usage"
|
||||
14
home/hypr/quickshell/scripts/get_mem.sh
Executable file
14
home/hypr/quickshell/scripts/get_mem.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# Read memory usage from /proc/meminfo
|
||||
mem_total=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
||||
mem_avail=$(grep MemAvailable /proc/meminfo | awk '{print $2}')
|
||||
|
||||
if [ -n "$mem_total" ] && [ -n "$mem_avail" ] && [ "$mem_total" -gt 0 ]; then
|
||||
mem_used=$((mem_total - mem_avail))
|
||||
mem_percent=$((mem_used * 100 / mem_total))
|
||||
used_gb=$(awk "BEGIN {printf \"%.1f\", $mem_used/1048576}")
|
||||
total_gb=$(awk "BEGIN {printf \"%.1f\", $mem_total/1048576}")
|
||||
echo "{\"percent\": $mem_percent, \"used_gb\": \"$used_gb\", \"total_gb\": \"$total_gb\"}"
|
||||
else
|
||||
echo "{\"percent\": 0, \"used_gb\": \"0\", \"total_gb\": \"0\"}"
|
||||
fi
|
||||
30
home/hypr/quickshell/scripts/get_wifi.sh
Executable file
30
home/hypr/quickshell/scripts/get_wifi.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
# Read WiFi status
|
||||
ssid=""
|
||||
ip=""
|
||||
|
||||
if command -v nmcli &>/dev/null; then
|
||||
active_line=$(nmcli -t -f active,ssid,signal dev wifi 2>/dev/null | grep '^yes' | head -n 1)
|
||||
if [ -n "$active_line" ]; then
|
||||
ssid=$(echo "$active_line" | cut -d':' -f2)
|
||||
signal=$(echo "$active_line" | cut -d':' -f3)
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$ssid" ]; then
|
||||
# Fallback to iwgetid or /proc/net/wireless
|
||||
if command -v iwgetid &>/dev/null; then
|
||||
ssid=$(iwgetid -r 2>/dev/null)
|
||||
fi
|
||||
fi
|
||||
|
||||
# Get default IPv4
|
||||
ip=$(ip -4 route get 1.1.1.1 2>/dev/null | awk '{print $7; exit}')
|
||||
|
||||
if [ -n "$ssid" ]; then
|
||||
echo "{\"connected\": true, \"ssid\": \"$ssid\", \"ip\": \"${ip:-N/A}\"}"
|
||||
elif [ -n "$ip" ]; then
|
||||
echo "{\"connected\": true, \"ssid\": \"Ethernet\", \"ip\": \"$ip\"}"
|
||||
else
|
||||
echo "{\"connected\": false, \"ssid\": \"Not Connected\", \"ip\": \"None\"}"
|
||||
fi
|
||||
Reference in New Issue
Block a user