Created
September 9, 2019 10:03
-
-
Save kamilogorek/7e8ebcca63fce3942d62abe2242f5a7c to your computer and use it in GitHub Desktop.
Revisions
-
kamilogorek created this gist
Sep 9, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,74 @@ package main import ( "fmt" "os" "os/exec" "strconv" "time" ) const standBanner = ` $$$$$$\ $$$$$$$$\ $$$$$$\ $$\ $$\ $$$$$$$\ $$\ $$\ $$$$$$$\ $$ __$$\\__$$ __|$$ __$$\ $$$\ $$ |$$ __$$\ $$ | $$ |$$ __$$\ $$ / \__| $$ | $$ / $$ |$$$$\ $$ |$$ | $$ | $$ | $$ |$$ | $$ | \$$$$$$\ $$ | $$$$$$$$ |$$ $$\$$ |$$ | $$ | $$ | $$ |$$$$$$$ | \____$$\ $$ | $$ __$$ |$$ \$$$$ |$$ | $$ | $$ | $$ |$$ ____/ $$\ $$ | $$ | $$ | $$ |$$ |\$$$ |$$ | $$ | $$ | $$ |$$ | \$$$$$$ | $$ | $$ | $$ |$$ | \$$ |$$$$$$$ | \$$$$$$ |$$ | \______/ \__| \__| \__|\__| \__|\_______/ \______/ \__| ` const seatBanner = ` $$$$$$\ $$$$$$$$\ $$$$$$\ $$$$$$$$\ $$$$$$$\ $$$$$$\ $$\ $$\ $$\ $$\ $$ __$$\ $$ _____|$$ __$$\\__$$ __| $$ __$$\ $$ __$$\ $$ | $\ $$ |$$$\ $$ | $$ / \__|$$ | $$ / $$ | $$ | $$ | $$ |$$ / $$ |$$ |$$$\ $$ |$$$$\ $$ | \$$$$$$\ $$$$$\ $$$$$$$$ | $$ | $$ | $$ |$$ | $$ |$$ $$ $$\$$ |$$ $$\$$ | \____$$\ $$ __| $$ __$$ | $$ | $$ | $$ |$$ | $$ |$$$$ _$$$$ |$$ \$$$$ | $$\ $$ |$$ | $$ | $$ | $$ | $$ | $$ |$$ | $$ |$$$ / \$$$ |$$ |\$$$ | \$$$$$$ |$$$$$$$$\ $$ | $$ | $$ | $$$$$$$ | $$$$$$ |$$ / \$$ |$$ | \$$ | \______/ \________|\__| \__| \__| \_______/ \______/ \__/ \__|\__| \__| ` var standSound = exec.Command("say", "Stand Up") var seatSound = exec.Command("say", "Seat Down") var standNotification = exec.Command("osascript", "-e", "display notification \"Stand Up\" with title \"Standing Desk Notifier\"") var seatNotification = exec.Command("osascript", "-e", "display notification \"Seat Down\" with title \"Standing Desk Notifier\"") func detailsBanner(duration time.Duration) string { // Mon Jan 2 15:04:05 MST 2006 timeFormat := "15:04" now := time.Now() return fmt.Sprintf("\n===============\n"+ "Start: %s\n"+ "End: %s\n"+ "Duration: %s\n"+ "===============", now.Format(timeFormat), now.Add(duration).Format(timeFormat), duration) } func startupBanner(standTime time.Duration, seatTime time.Duration) string { return fmt.Sprintf("\n=================\nStand Time: %s\nSeat Time: %s\n=================", standTime, seatTime) } func main() { standArg, _ := strconv.Atoi(os.Args[1]) standTime := time.Minute * time.Duration(standArg) seatArg, _ := strconv.Atoi(os.Args[2]) seatTime := time.Minute * time.Duration(seatArg) fmt.Println(startupBanner(standTime, seatTime)) for { fmt.Println(standBanner, detailsBanner(standTime)) standSound.Run() standNotification.Run() time.Sleep(standTime) fmt.Println(seatBanner, detailsBanner(seatTime)) seatSound.Run() seatNotification.Run() time.Sleep(seatTime) } }