shutd

package module
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2022 License: MIT Imports: 8 Imported by: 0

README ¶

🛑 Shutd

Auto shutdown utility tool for Windows with popup and snooze features

Screenshot

🔨 Build

-ldflags -H=windowsgui compile flags is to avoid opening a console at application startup

go install -ldflags -H=windowsgui ./cmd/shutd

🛠 Usage

If wanted to run it sliently (i.e. without any console popup) at start up, you may do the following

(Not sure why simply running shutd.exe in Startup with -ldflags -H=windowsgui could not trigger the shutdown properly)

  1. Create a shutd.vbs at any folder
Set WshShell = CreateObject("WScript.Shell") 
gopath = WshShell.ExpandEnvironmentStrings("%GOPATH%")
WshShell.Run chr(34) & gopath & "\bin\shutd.exe" & Chr(34), 0
Set WshShell = Nothing
  1. Create a shortcut and choose shutd.vbs that you created as target

  2. Move the shortcut to start up folder, simply search Startup from Windows explorer

  3. You should be able to see shutd.exe running in task manager next time when it starts up

âš™ Configuration

Following set of default configurations will be generated under home directory %USERPROFILE%/.shutd.yaml

Feel free to tweak it for your liking

After updated the configuration, shutd will automatically pick up the latest config, no need to restart it manually

startTime: "01:00"
snoozeInterval: 15
notification:
  before: 10
  duration: 10
Property Default Value Remarks
startTime "01:00" Time for auto shutdown
snoozeInterval 15 Minutes that will snooze for shutdown
notification.before 10 Minutes before shutdown for snooze popup notification
notification.duration 10 Minutes for snnoze popup notification to default to not snooze

📃 Logging

Log file will be generated under you home directory %USERPROFILE%/.shutd.log

Troubleshoot error there if wanted

🚢 Release

go install github.com/mitchellh/gox@latest

gox -os=windows -ldflags -H=windowsgui -output ./build/{{.Dir}}_{{.OS}}_{{.Arch}} ./cmd/shutd

📜 License

Distributed under the MIT License. See LICENSE for more information.

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

func WithLogger ¶

func WithLogger(logger *logrus.Logger) option

WithLogger option to allow passing of custom logger

func WithShutdownTask ¶

func WithShutdownTask(t SchedulerTask) option

WithShutdownTask option to allow passing of custom shutdown task

func WithSnoozeNotificationTask ¶

func WithSnoozeNotificationTask(t SchedulerTask) option

WithSnoozeNotificationTask option to allow passing of custom snooze notification task, Scheduler.Snooze function can snooze it

Types ¶

type Config ¶

type Config struct {
	SnoozeInterval int
	StartTime      string
	Notification   struct {
		Before   int
		Duration int
	}
}

Config for shutdown scheduler

type Scheduler ¶

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler for auto shutdown the computer

func NewScheduler ¶

func NewScheduler(config Config, options ...option) (*Scheduler, error)

NewScheduler to create scheduler to shutdown the computer

func (*Scheduler) Config ¶

func (s *Scheduler) Config() Config

Config get config of the scheduler

func (*Scheduler) Configure ¶

func (s *Scheduler) Configure(config Config) error

Configure scheduler for updated config

func (*Scheduler) Logger ¶

func (s *Scheduler) Logger() *logrus.Logger

Logger get logger of the scheduler

func (*Scheduler) ShutdownTime ¶

func (s *Scheduler) ShutdownTime() (time.Time, error)

ShutdownTime get next shutdown time

func (*Scheduler) ShutdownTimeChangedChan ¶

func (s *Scheduler) ShutdownTimeChangedChan() chan time.Time

ShutdownTimeChangedChan get channel of latest shutdown time

func (*Scheduler) Snooze ¶

func (s *Scheduler) Snooze() error

Snooze to delay shutdown time for the computer

type SchedulerTask ¶

type SchedulerTask func(s *Scheduler) error

SchedulerTask for scheduler to shutdown or notify for snooze

Directories ¶

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL