2013-07-05 14:46:45 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2014-10-09 12:55:20 +00:00
|
|
|
|
|
|
|
"github.com/vbatts/go-lockout/config"
|
2013-07-05 14:46:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var (
|
|
|
|
c *config.Config
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
|
|
|
c, err = config.ReadConfig(DefaultConfig)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "ERROR: %s\n", err)
|
|
|
|
fmt.Fprintf(os.Stderr, UsageMessage)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
//fmt.Printf("%#v\n", c)
|
|
|
|
|
|
|
|
err = c.Lock()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "ERROR: %s\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
err = c.Suspend()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "ERROR: %s\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
DefaultConfig = os.Getenv("HOME") + "/.config/lockout.conf"
|
|
|
|
UsageMessage = `
|
|
|
|
Please configure this file to look something like
|
|
|
|
|
|
|
|
suspendcmd: sudo /usr/sbin/pm-suspend
|
|
|
|
lockcmd: xscreensaver-command -lock
|
|
|
|
|
2014-10-09 12:55:20 +00:00
|
|
|
noxsuspendcmd: sudo /usr/sbin/pm-suspend
|
|
|
|
noxlockcmd: clear
|
2013-07-05 14:46:45 +00:00
|
|
|
`
|
|
|
|
)
|