Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-ha committed Mar 13, 2024
1 parent 4143b70 commit f04da25
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions sleepless/sleepless_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@ func PreventSleep(appName string, reason string) (func(), error) {

var cookie uint
objectPath := dbus.ObjectPath("/org/gnome/SessionManager")
ifaceName := "org.gnome.SessionManager"

conn.Object("org.gnome.SessionManager", objectPath).Call(
ifaceName+".Inhibit",
0, // Flags
"jcp", // App Name
uint32(0), // Flags
"Copy is in progress", // Reason
uint32(1), // Flags
conn.Object("org.gnome.SessionManager", objectPath).Call("org.gnome.SessionManager.Inhibit",
0,
"jcp",
uint32(0),
"Copy is in progress",
uint32(1),
).Store(&cookie)

return func() {
conn.Object("org.gnome.SessionManager", objectPath).Call(
ifaceName+".Uninhibit",
0, // Flags
"org.gnome.SessionManager.Uninhibit",
0,
cookie)
conn.Close()
}, nil
Expand Down

0 comments on commit f04da25

Please sign in to comment.