~kris/dots

srice

ref: e98f3b030dc24445bd55c68d95d2d81933fd68b3 srice/.config/eww/scripts/profile.sh -rw-r--r-- 1.3 KiB
e98f3b03 — Kris Yotam chore: sync local state after restore (push updates, no pull) a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash

# SETTINGS
IMAGE_URL="file:///home/$USER/.config/eww/assets/profile.jpg"

# Fungsi Helper untuk WM (biar rapi)
get_wm() {
    if pgrep -x "i3" > /dev/null; then echo "i3";
    elif pgrep -x "bspwm" > /dev/null; then echo "bspwm";
    elif pgrep -x "awesome" > /dev/null; then echo "awesome";
    elif pgrep -x "dwm" > /dev/null; then echo "dwm";
    elif pgrep -x "hyprland" > /dev/null; then echo "hyprland";
    elif [ "$XDG_CURRENT_DESKTOP" ]; then echo "$XDG_CURRENT_DESKTOP";
    else echo "Unknown"; fi
}

# Fungsi Helper untuk Uptime Short
get_uptime() {
    uptime -p | sed 's/up //' | sed 's/ hours/h/' | sed 's/ hour/h/' | sed 's/ minutes/m/' | sed 's/ minute/m/' | sed 's/,//'
}

case "$1" in
    json)
        # --- BAGIAN BARU: SATU PAKET JSON ---
        # Kita panggil fungsi di atas dan simpan ke variabel
        wm_name=$(get_wm)
        up_time=$(get_uptime)
        
        # Output format JSON
        echo "{\"username\": \"$USER\", \"wm\": \"$wm_name\", \"uptime\": \"$up_time\", \"image\": \"$IMAGE_URL\"}"
        ;;

    # --- KOMPATIBILITAS LAMA (Opsional, boleh dibiarkan) ---
    username) echo "$USER" ;;
    wm) get_wm ;;
    uptime) uptime -p | sed 's/up //' ;;
    uptime-short) get_uptime ;;
    image-url) echo "$IMAGE_URL" ;;
    
    *)
        echo "Usage: $0 {json|username|wm|uptime|image-url}"
        exit 1
        ;;
esac