sleeppls

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: MIT Imports: 12 Imported by: 0

README

SleepPls

SleepPls is a CLI application that helps you fall asleep. This application turns off the device at a certain time and notifies the shutdown in some time.

Installation

go install github.com/nezbut/sleeppls/cmd/sleeppls-cli@latest

or

Clone the repository and install local:

make install

bin sleeppls-cli will be installed in $GOPATH/bin

After installation and the first run you will have a picture that you need for DesktopNotifier, it will appear in the path you specified in -nicon, default is $HOME/SleepPls_notify_icon.png.

Usage

sleeppls-cli --help

2025/05/07 19:15:47 Usage of SleepPls:
  -nicon string
        The path to the notification icon. (default "$HOME/SleepPls_notify_icon.png")
  -ntf string
        The time it takes for the app to notify you when the device is turned off. (default "1h")
  -t string
        The time at which the device is forced to shut down. You can specify the format "YYYY-MM-DD HH:MM:SS" or HH:MM:SS if today (default "23:59:59")
  -tg string
        The token of the Telegram bot used to send notifications.
  -tgchat int
        The ID of the Telegram chat where notifications will be sent.

How it works

The app can turn off your device at 23:30:30 and will notify you 1 hour before shutting it down

sleeppls-cli -t "23:30:30" -ntf "1h"

By default the notification comes only via DesktopNotifier, but you can specify the token of the Telegram bot and the chat where the notification will also be sent via TelegramBotNotifier.

sleeppls-cli -t "23:30:30" -ntf "1h" -tg "<token>" -tgchat 123

You can also specify a custom path to the picture to be used in DesktopNotifier

sleeppls-cli -t "23:30:30" -ntf "1h" -nicon "/path/to/icon.png"

License

MIT License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTGResponseNotOK = fmt.Errorf("telegram response not ok")
)

Functions

This section is empty.

Types

type ComputerShutDowner

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

func (*ComputerShutDowner) ShutDown

func (s *ComputerShutDowner) ShutDown() error

type DesktopNotifier

type DesktopNotifier struct {
	IconPath string
}

Desktop Notifier

func (DesktopNotifier) Notify

func (d DesktopNotifier) Notify(msg string) error

func (DesktopNotifier) String

func (d DesktopNotifier) String() string

type Notifier

type Notifier interface {
	Notify(msg string) error
	String() string
}

Notifier interface

func NewDesktopNotifier

func NewDesktopNotifier(IconPath string) Notifier

func NewTelegramBotNotifier

func NewTelegramBotNotifier(client *http.Client, token string, chatID int) (Notifier, error)

type ShutDowner

type ShutDowner interface {
	ShutDown() error
}

func NewComputerShutDowner

func NewComputerShutDowner(Os string) ShutDowner

type TelegramBotNotifier

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

TelegramBot Notifier

func (*TelegramBotNotifier) Notify

func (tg *TelegramBotNotifier) Notify(msg string) error

func (*TelegramBotNotifier) String

func (tg *TelegramBotNotifier) String() string

Directories

Path Synopsis
cmd
sleeppls-cli command

Jump to

Keyboard shortcuts

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