daemon

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: Unlicense Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Socket net.Listener
	X      *xgbutil.XUtil

	KeyPressCommands     = NewHotkeyMap()
	KeyPressDescriptions = NewHotkeyMap()

	KeyReleaseCommands     = NewHotkeyMap()
	KeyReleaseDescriptions = NewHotkeyMap()
)

Functions

func AddEventInfo

func AddEventInfo(infos *string, hotkey string, eventName string, description string)

AddEventInfo handles the logic behind creating a new line and filling it with the infos necessary for the 'info' command for each bound hotkey

func Bind

func Bind(bindArgs common.BindCmd) error

Bind does the heavy work of binding a hotkey (plus its eventual sisters) to a command.

func Exec

func Exec(command string)

Exec executes the given sh command string. This method is blocking.

func GetAllInfo

func GetAllInfo() (info string)

GetAllInfo creates a string with all the bound hotkeys there are, both those bound on press and those bound on release.

func GetInfo

func GetInfo(hotkeyStr string) (res common.Response)

GetInfo returns the information about what is bound to the given hotkeyStr. It returns a Response structure to easily accomodate the need to mention parsing errors if the hotkeyStr is "naughty". The first Hotkey to be parsed should be the main one, which represents our needed description in the description maps.

func GetSocket

func GetSocket(socketPath string) (socket net.Listener, err error)

func HandleConnection

func HandleConnection(conn net.Conn)

func HandleEvent

func HandleEvent(event xgb.Event)

func HandleHotkeys

func HandleHotkeys()

func MakeDescription

func MakeDescription(description string, command string) string

MakeDescription handles the logic behind generating a dummy description for the commands which don't come with a description (i.e. it is empty) from the command string, or returning the description if it isn't empty

func SocketLoop

func SocketLoop()

func StartDaemon

func StartDaemon(args common.Args) int

func Unbind

func Unbind(unbindArgs common.UnbindCmd) error

Unbind does the not-so-heavy work of unbinding a hotkey (plus its eventual sisters), which consists in ungrabbing the keys, and deleting the keys in the HotkeyMap's

Types

type Hotkey

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

func HotkeysFromStr

func HotkeysFromStr(str string) (hotkeys []Hotkey, err error)

HotkeysFromStr parses a hotkey string and returns the according Hotkey's. Mods are unambiguous (though we ignore here the Num and Caps Lock). Keycodes aren't, though. For instance, on some layouts, there are 2 keys with different keycodes which map to 'backslash' AKA '\'. And we want to handle them both. This is why we return an array of Hotkey's here. And an error if the string is "naughty".

func (Hotkey) Grab

func (h Hotkey) Grab() error

func (Hotkey) ToStr

func (h Hotkey) ToStr() (str string)

ToStr converts the Hotkey into its string representation. This helps us show in a human-firendly way the bound hotkeys in the 'info' command.

func (Hotkey) Ungrab

func (h Hotkey) Ungrab()

type HotkeyMap

type HotkeyMap struct {
	Map    map[Hotkey]string
	RWLock sync.RWMutex
}

func NewHotkeyMap

func NewHotkeyMap() HotkeyMap

func (*HotkeyMap) Delete

func (m *HotkeyMap) Delete(hotkey Hotkey)

func (*HotkeyMap) ForEach

func (m *HotkeyMap) ForEach(fn func(Hotkey, string))

func (*HotkeyMap) Get

func (m *HotkeyMap) Get(hotkey Hotkey) string

func (*HotkeyMap) IsEmpty

func (m *HotkeyMap) IsEmpty(hotkey Hotkey) bool

func (*HotkeyMap) Set

func (m *HotkeyMap) Set(hotkey Hotkey, command string)

Jump to

Keyboard shortcuts

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