backlight

package module
v0.0.0-...-b725ea4 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 9 Imported by: 0

README

barista-backlight

A module for the barista status bar to display and control the screen brightness.

Usage

package main

import (
    "barista.run"
    "barista.run/bar"
    "barista.run/outputs"
  
    "github.com/jakobgrine/barista-backlight"
)

func main() {
    barista.Add(backlight.New("acpi_video0").Output(func(b *backlight.Backlight) bar.Output {
        return outputs.Textf("%d%%", b.Percent())
    }))
  
    panic(barista.Run())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backlight

type Backlight struct {
	Bri    int
	Max    int
	Kernel string
}

Backlight holds information about the current state of the screen backlight.

func NewBacklight

func NewBacklight(kernel string) *Backlight

NewBacklight creates a new instance of Backlight.

func (*Backlight) Fraction

func (b *Backlight) Fraction() float64

Fraction returns the brightness as a fraction of the maximum value.

func (*Backlight) Get

func (b *Backlight) Get() error

Get updates the Bri and Max values after reading the respective files.

func (*Backlight) Percent

func (b *Backlight) Percent() int

Percent returns the brightness in percent of the maximum value.

func (*Backlight) SetBrightness

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

SetBrightness sets the screen brightness.

type Module

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

Module is the barista module for controlling the screen backlight of laptops.

func New

func New(kernel string) *Module

New creates a new instance of Module.

func (*Module) Output

func (m *Module) Output(format func(b *Backlight) bar.Output) *Module

Output sets the format function to enable custom output formats.

func (*Module) Stream

func (m *Module) Stream(s bar.Sink)

Stream is the barista stream function to update the status bar state.

Jump to

Keyboard shortcuts

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