lis

package module
v0.0.0-...-3e0dfdd Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

README

lis - backlight daemon

Travis BuildStatus

lis is a daemon to automatically dim/undim the screen backlight when a user is idling/active, thus conserving energy and improving battery life.

Dependencies
  • libx11
  • libxss
  • systemd >= 183

lisc

Commands
lisc set 50%
lisc set -5%
lisc set +5%

lisc status

lisc dpms off
lisc dpms on
Protocol
SET 50%
SET -5%
SET +5%
STATUS
DPMS OFF
DPMS ON

Response:

OK (optional msg)
ERROR err msg

LICENSE

Copyright (C) 2016-2018 Mikkel Oscar Lyderik Larsen

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func XIdle

func XIdle() (uint, error)

XIdle returns the xserver idle time in miliseconds.

Types

type Backlight

type Backlight struct {
	Max int
	// contains filtered or unexported fields
}

Backlight defines a backlight class from /sys/class/backlight.

func NewBacklight

func NewBacklight(syspath string) (*Backlight, error)

NewBacklight sets up a backlight struct.

func (*Backlight) ActualPath

func (b *Backlight) ActualPath() string

ActualPath gets the sys-path to actual_brightness.

func (*Backlight) Dim

func (b *Backlight) Dim(start, end int, errChan chan error)

Dim backlight from start to end.

func (*Backlight) Get

func (b *Backlight) Get() (int, error)

Get actual brightness value.

func (*Backlight) ReadMax

func (b *Backlight) ReadMax() (int, error)

ReadMax get max brightness value.

func (*Backlight) Set

func (b *Backlight) Set(value int) error

Set brightness value.

func (*Backlight) UnDim

func (b *Backlight) UnDim(start, end int, errChan chan error)

UnDim backlight from start to end.

type Config

type Config struct {
	StateFile string `toml:"statefile"`
	Backlight string `toml:"backlight"`
	IdleTime  uint   `toml:"idle"`
}

Config defines the lis config struct.

func ReadConfig

func ReadConfig(filePath string) (*Config, error)

ReadConfig reads the config from filePath.

type DBusHandler

type DBusHandler struct {
	Signal chan *dbus.Signal
	// contains filtered or unexported fields
}

DBusHandler handles a DBus connection to receive signal on suspend.

func NewDBusHandler

func NewDBusHandler(lis *Lis) (*DBusHandler, error)

NewDBusHandler initializes a new DBusHandler.

func (*DBusHandler) Close

func (d *DBusHandler) Close()

Close closes the inhibit file.

func (*DBusHandler) Run

func (d *DBusHandler) Run(errCh chan error)

Run starts the DBusHandler event loop.

type IPCClient

type IPCClient struct {
	net.Conn
}

IPCClient defines an IPC client for communicating with the lis IPC server.

func (*IPCClient) DPMS

func (i *IPCClient) DPMS(value string) error

DPMS sets the enables/disables DPMS via IPC.

func (*IPCClient) RPC

func (i *IPCClient) RPC(msg string, args ...interface{}) (interface{}, error)

RPC sends a message to the IPC server and handles the response.

func (*IPCClient) Set

func (i *IPCClient) Set(value string) error

Set sets the brightness value via IPC.

func (*IPCClient) Status

func (i *IPCClient) Status() (string, error)

Status gets the brightness status via IPC.

type IPCCmd

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

IPCCmd defines an IPC command.

type IPCCmdType

type IPCCmdType int

IPCCmdType defines the type of IPC command.

const (
	// IPCSet is the command for setting a brightness value.
	IPCSet IPCCmdType = iota
	// IPCSetUp is the command for increasing the brightness value.
	IPCSetUp
	// IPCSetDown is the command for decreasing the brightness value.
	IPCSetDown
	// IPCStatus is the command for getting current brightness value.
	IPCStatus
	// IPCDPMSOn is the command for enabling DPMS.
	IPCDPMSOn
	// IPCDPMSOff is the command for disabling DPMS.
	IPCDPMSOff
)

type IPCServer

type IPCServer struct {
	net.Listener
}

IPCServer is a server for inter process communication on a unix socket.

func NewIPCServer

func NewIPCServer() (*IPCServer, error)

NewIPCServer intializes a new IPC server.

func (*IPCServer) Run

func (i *IPCServer) Run(ipcCh chan<- IPCCmd, errCh chan<- error)

Run runs the IPC server.

type InputDevs

type InputDevs struct {
	Activity chan struct{}
	// contains filtered or unexported fields
}

InputDevs defines a map of valid input devices.

func GetInputDevices

func GetInputDevices(errors chan error) (*InputDevs, error)

GetInputDevices return a InputDevs containing valid input devices.

func (*InputDevs) Wait

func (devices *InputDevs) Wait(heartbeat chan struct{})

Wait monitor and wait for input events and shut down on event.

type Lis

type Lis struct {
	IPC chan IPCCmd // ipc channel used to communicate with the IPC server
	// contains filtered or unexported fields
}

Lis defines the core state of the lis daemon.

func NewLis

func NewLis(config *Config) (*Lis, error)

NewLis creates a new Lis instance.

func (*Lis) GetPercent

func (l *Lis) GetPercent() (float64, error)

GetPercent gets the current backlight value as a percent value. (max/current).

func (*Lis) Run

func (l *Lis) Run(ctx context.Context) error

Run runs the lis main loop.

func (*Lis) SetPercent

func (l *Lis) SetPercent(value float64) error

SetPercent sets the current value from a percent value. (max * value).

type StateFile

type StateFile string

StateFile is a path to the lis state file.

func (StateFile) Read

func (s StateFile) Read() (uint16, error)

Read value from stateFile.

func (StateFile) Write

func (s StateFile) Write(value uint16) error

Write value to stateFile.

Directories

Path Synopsis
cmd
lis

Jump to

Keyboard shortcuts

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