Skip to content

jelmerdehen/xidle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xidle

Run functions based on idle state in Xorg.

Usage

Example with callbacks and durations:

package main

import (
	"log"
	"time"

	"github.com/JelmerDeHen/xidle"
)

func main() {
	idlemon := &xidle.Idlemon{
		Poll: func() {
			log.Println("Polling")
		},
		PollInterval: time.Second,
		IdleLess: func() {
			log.Println("Present")
		},
		IdleLessTimeout: time.Second * 3,
		IdleOver: func() {
			log.Println("User afk")
		},
		IdleOverTimeout: time.Second * 3,
	}
	idlemon.Run()
}

Run application

Run application when user is present and kill app when afk.

package main

import (
  "github.com/JelmerDeHen/xidle"
)

func main() {
	runner := xidle.NewCmdJob("sleep", "1337")
	idlemon := xidle.NewIdlemon(runner)
	idlemon.Run()
}

Default behavior:

  • When not idle during last minute spawn the application
  • When idle over 10 minutes kill the application

Examples

About

Run commands based on idle time in xorg

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages