@@ -3,6 +3,7 @@ package wallutils
33import (
44 "fmt"
55 "net"
6+ "os/user"
67 "path"
78
89 "github.com/xyproto/env/v2"
@@ -22,14 +23,35 @@ func (sb *Hyprpaper) Name() string {
2223
2324// ExecutablesExists checks if executables associated with this backend exists in the PATH
2425func (sb * Hyprpaper ) ExecutablesExists () bool {
25- return which ("hyprpaper" ) != ""
26+ return which ("hyprpaper" ) != "" // && which("hyprctl") != ""
2627}
2728
28- // Running examines environment variables to try to figure out if this backend is currently running
29+ // Running examines environment variables to try to figure out if this backend is currently running.
30+ // Also sets sb.sock to an empty string or to a UNIX socket file.
2931func (sb * Hyprpaper ) Running () bool {
32+ sb .sock = ""
33+
3034 inst := env .Str ("HYPRLAND_INSTANCE_SIGNATURE" )
31- sb .sock = path .Join ("/tmp/hypr" , inst , ".hyprpaper.sock" )
32- return exists (sb .sock )
35+ if inst == "" {
36+ return false // HYPRLAND_INSTANCE_SIGNATURE is not set
37+ }
38+
39+ currentUser , err := user .Current ()
40+ if err != nil || currentUser .Uid == "" {
41+ return false // could not get the user ID of the current user
42+ }
43+
44+ if sock := path .Join ("/run/user/" + currentUser .Uid + "/hypr/" + inst + "/.hyprpaper.sock" ); exists (sock ) {
45+ sb .sock = sock
46+ return true
47+ }
48+
49+ if sock := path .Join ("/tmp/hypr" , inst , ".hyprpaper.sock" ); exists (sock ) {
50+ sb .sock = sock
51+ return true
52+ }
53+
54+ return false // env.Contains("XDG_SESSION_DESKTOP", "Hyprland") || env.Contains("DESKTOP_SESSION", "hyprland")
3355}
3456
3557// SetMode will set the current way to display the wallpaper (stretched, tiled etc)
0 commit comments