go-lockout/lockout/main.go

45 lines
737 B
Go
Raw Normal View History

2013-07-05 14:46:45 +00:00
package main
import (
"fmt"
"github.com/vbatts/go-lockout/config"
"os"
)
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
`
)