go-lockout/lockout/main.go

47 lines
801 B
Go

package main
import (
"fmt"
"os"
"github.com/vbatts/go-lockout/config"
)
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
noxsuspendcmd: sudo /usr/sbin/pm-suspend
noxlockcmd: clear
`
)