utils

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package utils provides utility functions.

Index

Constants

View Source
const XDGRuntimeDir = "XDG_RUNTIME_DIR"

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(b bool) *bool

func EscapeHyprDescription added in v1.3.3

func EscapeHyprDescription(desc string) string

EscapeHyprDescription escapes # characters in monitor descriptions by doubling them. In Hyprland's configuration syntax, # needs to be escaped as ## when used in desc: fields.

func FormatEnumTypes added in v0.1.0

func FormatEnumTypes[T HasValue](enums []T) string

func GetFunctionName

func GetFunctionName(i interface{}) string

func GetPowerLine added in v1.3.0

func GetPowerLine() (*string, error)

func GetRunCmd added in v1.3.0

func GetRunCmd() cmdRunner

GetRunCmd returns the current command runner (for testing)

func GetXDGRuntimeDir

func GetXDGRuntimeDir() (string, error)

func IntPtr

func IntPtr(i int) *int

func IsLaptop added in v1.3.5

func IsLaptop() bool

func JustPtr added in v0.1.0

func JustPtr[T any](v T) *T

func PrettyPrintError added in v1.4.0

func PrettyPrintError(err error)

func Reverse added in v1.3.4

func Reverse(s string) string

func SetRunCmd added in v1.3.0

func SetRunCmd(r cmdRunner)

SetRunCmd sets the command runner (for testing)

func SignalBodyToString added in v1.3.0

func SignalBodyToString(v interface{}) string

SignalBodyToString recursively converts any DBus body item into a string

func StringPtr

func StringPtr(s string) *string

func UnmarshalResponse

func UnmarshalResponse[T any](response []byte, v *T) error

func WriteAtomic added in v0.1.0

func WriteAtomic(filename string, data []byte) error

Types

type DebounceFn added in v0.1.0

type DebounceFn func(context.Context) error

type Debouncer added in v0.1.0

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

func NewDebouncer added in v0.1.0

func NewDebouncer() *Debouncer

func (*Debouncer) Cancel added in v0.1.0

func (d *Debouncer) Cancel()

Cancel drops any pending job without running it.

func (*Debouncer) Do added in v0.1.0

func (d *Debouncer) Do(parent context.Context, delay time.Duration, fn DebounceFn)

Do schedules fn to run after delay. If another Do arrives before the timer fires, the previous pending call is canceled and replaced by this one. parent provides the context for the eventual job execution.

func (*Debouncer) Run added in v0.1.0

func (d *Debouncer) Run(ctx context.Context) error

type HasValue added in v0.1.0

type HasValue interface {
	Value() string
}

type LogID added in v0.1.0

type LogID int
const (
	UnknownLogID LogID = iota
	DryRunLogID
	PreExecLogID
	PostExecLogID
	DisablingPowerEventsLogID
	DryRunSymlinkLogID
	DryRunTemplateLogID
	DryRunExedLogID
	DryRunNotificationLogID
)

type LogrusCustomFields added in v0.1.0

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

func NewLogrusCustomFields added in v0.1.0

func NewLogrusCustomFields(fields map[string]interface{}) *LogrusCustomFields

func NewLogrusEmptyFields added in v0.1.0

func NewLogrusEmptyFields() *LogrusCustomFields

func (*LogrusCustomFields) WithLogID added in v0.1.0

func (l *LogrusCustomFields) WithLogID(id LogID) logrus.Fields

Jump to

Keyboard shortcuts

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