shortcuts

package
v0.0.0-...-61f35a2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShortcutTypeSystem int32 = iota
	ShortcutTypeCustom
	ShortcutTypeMedia
	ShortcutTypeWM
	ShortcutTypeFake
)
View Source
const (
	SKLCtrlShift uint32 = 1 << iota
	SKLAltShift
	SKLSuperSpace
)
View Source
const ActionTypeCount = int(actionTypeMax)

Variables

View Source
var ActionNoOp = &Action{Type: ActionTypeNonOp}
View Source
var ErrInvalidActionType = errors.New("invalid action type")
View Source
var ErrNilAction = errors.New("action is nil")
View Source
var ErrOpNotSupported = errors.New("operation is not supported")

errors:

View Source
var ErrTypeAssertionFail = errors.New("type assertion failed")

Functions

func GetKeyFirstCode

func GetKeyFirstCode(keySymbols *keysyms.KeySymbols, str string) (x.Keycode, error)

func GetQtKeycodeMap

func GetQtKeycodeMap() map[string]string

func GetSystemActionCmd

func GetSystemActionCmd(id string) string

func SetLogger

func SetLogger(l *log.Logger)

Types

type Action

type Action struct {
	Type ActionType
	Arg  interface{}
}

func GetAction

func GetAction(id string) *Action

func NewAudioCtrlAction

func NewAudioCtrlAction(cmd ActionCmd) *Action

func NewCallbackAction

func NewCallbackAction(fn func(ev *KeyEvent)) *Action

func NewDisplayCtrlAction

func NewDisplayCtrlAction(cmd ActionCmd) *Action

func NewExecCmdAction

func NewExecCmdAction(cmd string, execOnRelease bool) *Action

func NewKbdBrightnessCtrlAction

func NewKbdBrightnessCtrlAction(cmd ActionCmd) *Action

func NewMediaPlayerCtrlAction

func NewMediaPlayerCtrlAction(cmd ActionCmd) *Action

func NewOpenMimeTypeAction

func NewOpenMimeTypeAction(mimeType string) *Action

run the program which default handle mimeType

func NewTouchpadCtrlAction

func NewTouchpadCtrlAction(cmd ActionCmd) *Action

type ActionCmd

type ActionCmd uint
const (
	// audio ctrl
	AudioSinkMuteToggle ActionCmd = iota + 1
	AudioSinkVolumeUp
	AudioSinkVolumeDown
	AudioSourceMuteToggle

	// media play ctrl
	MediaPlayerPlay
	MediaPlayerPause
	MediaPlayerStop
	MediaPlayerPrevious
	MediaPlayerNext
	MediaPlayerRewind
	MediaPlayerForword
	MediaPlayerRepeat

	// display ctrl
	MonitorBrightnessUp
	MonitorBrightnessDown
	DisplayModeSwitch
	AdjustBrightnessSwitch

	// keyboard backlight ctrl
	KbdLightToggle
	KbdLightBrightnessUp
	KbdLightBrightnessDown

	// touchpad ctrl
	TouchpadToggle
	TouchpadOn
	TouchpadOff
)

type ActionExecCmdArg

type ActionExecCmdArg struct {
	ExecOnRelease bool
	Cmd           string
}

exec commandline

type ActionType

type ActionType uint
const (
	ActionTypeNonOp ActionType = iota
	ActionTypeExecCmd
	ActionTypeOpenMimeType
	ActionTypeDesktopFile
	ActionTypeShowNumLockOSD
	ActionTypeShowCapsLockOSD
	ActionTypeSystemShutdown
	ActionTypeSystemSuspend
	ActionTypeSystemLogOff
	ActionTypeSystemAway

	// controllers
	ActionTypeAudioCtrl
	ActionTypeMediaPlayerCtrl // MPRIS
	ActionTypeDisplayCtrl
	ActionTypeKbdLightCtrl
	ActionTypeTouchpadCtrl

	ActionTypeSwitchKbdLayout

	ActionTypeToggleWireless
	ActionTypeShowControlCenter

	ActionTypeCallback // 触发回调函数点Action

)

type BaseShortcut

type BaseShortcut struct {
	Id         string
	Type       int32
	Keystrokes []*Keystroke `json:"Accels"`
	Name       string
	// contains filtered or unexported fields
}

func (*BaseShortcut) GetAction

func (sb *BaseShortcut) GetAction() *Action

func (*BaseShortcut) GetId

func (sb *BaseShortcut) GetId() string

func (*BaseShortcut) GetKeystrokes

func (sb *BaseShortcut) GetKeystrokes() []*Keystroke

func (*BaseShortcut) GetKeystrokesModifiable

func (sb *BaseShortcut) GetKeystrokesModifiable() bool

func (*BaseShortcut) GetName

func (sb *BaseShortcut) GetName() string

func (*BaseShortcut) GetNameBlocks

func (sb *BaseShortcut) GetNameBlocks() pinyin_search.Blocks

func (*BaseShortcut) GetType

func (sb *BaseShortcut) GetType() int32

func (*BaseShortcut) GetUid

func (sb *BaseShortcut) GetUid() string

func (*BaseShortcut) Marshal

func (sb *BaseShortcut) Marshal() (string, error)

func (*BaseShortcut) ShouldEmitSignalChanged

func (sb *BaseShortcut) ShouldEmitSignalChanged() bool

func (*BaseShortcut) String

func (sb *BaseShortcut) String() string

type CustomShortcut

type CustomShortcut struct {
	BaseShortcut

	Cmd string `json:"Exec"`
	// contains filtered or unexported fields
}

func (*CustomShortcut) GetAction

func (cs *CustomShortcut) GetAction() *Action

func (*CustomShortcut) Marshal

func (cs *CustomShortcut) Marshal() (string, error)

func (*CustomShortcut) ReloadKeystrokes

func (cs *CustomShortcut) ReloadKeystrokes() bool

经过 Reset 重置后, 自定义快捷键的 keystrokes 被设置为空,始终返回 false 是为了另外计算改变的自定义快捷键项目。

func (*CustomShortcut) Save

func (cs *CustomShortcut) Save() error

func (*CustomShortcut) SaveKeystrokes

func (cs *CustomShortcut) SaveKeystrokes() error

func (*CustomShortcut) SetName

func (cs *CustomShortcut) SetName(name string)

func (*CustomShortcut) ShouldEmitSignalChanged

func (cs *CustomShortcut) ShouldEmitSignalChanged() bool

type CustomShortcutManager

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

func NewCustomShortcutManager

func NewCustomShortcutManager(file string) *CustomShortcutManager

func (*CustomShortcutManager) Add

func (csm *CustomShortcutManager) Add(name, action string, keystrokes []*Keystroke) (Shortcut, error)

func (*CustomShortcutManager) Delete

func (csm *CustomShortcutManager) Delete(id string) error

func (*CustomShortcutManager) List

func (csm *CustomShortcutManager) List() []Shortcut

func (*CustomShortcutManager) Save

func (csm *CustomShortcutManager) Save() error

type FakeShortcut

type FakeShortcut struct {
	BaseShortcut
	// contains filtered or unexported fields
}

func NewFakeShortcut

func NewFakeShortcut(action *Action) *FakeShortcut

func (*FakeShortcut) GetAction

func (s *FakeShortcut) GetAction() *Action

func (*FakeShortcut) ReloadKeystrokes

func (s *FakeShortcut) ReloadKeystrokes() bool

func (*FakeShortcut) SaveKeystrokes

func (s *FakeShortcut) SaveKeystrokes() error

type GSettingsShortcut

type GSettingsShortcut struct {
	BaseShortcut
	// contains filtered or unexported fields
}

func NewGSettingsShortcut

func NewGSettingsShortcut(gsettings *gio.Settings, id string, type0 int32,
	keystrokes []string, name string) *GSettingsShortcut

func (*GSettingsShortcut) ReloadKeystrokes

func (gs *GSettingsShortcut) ReloadKeystrokes() bool

func (*GSettingsShortcut) SaveKeystrokes

func (gs *GSettingsShortcut) SaveKeystrokes() error

type Key

type Key struct {
	Mods Modifiers
	Code Keycode
}

func (Key) Grab

func (k Key) Grab(conn *x.Conn) error

func (Key) String

func (k Key) String() string

func (Key) ToKeystroke

func (k Key) ToKeystroke(keySymbols *keysyms.KeySymbols) *Keystroke

func (Key) Ungrab

func (k Key) Ungrab(conn *x.Conn)

type KeyEvent

type KeyEvent struct {
	Mods     Modifiers
	Code     Keycode
	Shortcut Shortcut
}

type KeyEventFunc

type KeyEventFunc func(ev *KeyEvent)

type Keycode

type Keycode x.Keycode

type Keystroke

type Keystroke struct {
	Mods     Modifiers
	Keystr   string
	Keysym   x.Keysym
	Shortcut Shortcut
	// contains filtered or unexported fields
}

Keystroke field Mods ignore mod2(Num_Lock) and lock(Caps_Lock)

func ParseKeystroke

func ParseKeystroke(keystroke string) (*Keystroke, error)

<Super>L mods (mod4) key L <Super>% mods (mod4, shift) key % <Control><Alt>T mods (control,mod1) key T <Control><shift>T mods(control,shift) key T <Control>> mods(control) key > <Control>< invalid Super< invalid <Super> mods() key Super Print mods() key Print <Control>Print mods(Control) key Print check Keystroke.Keystr valid later

func ParseKeystrokes

func ParseKeystrokes(keystrokes []string) []*Keystroke

func (*Keystroke) DebugString

func (ks *Keystroke) DebugString() string

func (*Keystroke) Equal

func (a *Keystroke) Equal(keySymbols *keysyms.KeySymbols, b *Keystroke) bool

func (*Keystroke) IsGood

func (ks *Keystroke) IsGood() bool

func (*Keystroke) MarshalJSON

func (ks *Keystroke) MarshalJSON() ([]byte, error)

func (*Keystroke) String

func (ks *Keystroke) String() string

func (*Keystroke) ToKey

func (ks *Keystroke) ToKey(keySymbols *keysyms.KeySymbols) (Key, error)

func (*Keystroke) ToKeyList

func (ks *Keystroke) ToKeyList(keySymbols *keysyms.KeySymbols) ([]Key, error)

type MediaShortcut

type MediaShortcut struct {
	*GSettingsShortcut
}

func (*MediaShortcut) GetAction

func (ms *MediaShortcut) GetAction() *Action

type Modifiers

type Modifiers uint16

func GetConcernedModifiers

func GetConcernedModifiers(state uint16) Modifiers

func (Modifiers) String

func (mods Modifiers) String() string

type Shortcut

type Shortcut interface {
	GetId() string
	GetUid() string
	GetType() int32

	GetName() string
	GetNameBlocks() pinyin_search.Blocks

	GetKeystrokesModifiable() bool
	GetKeystrokes() []*Keystroke

	SaveKeystrokes() error
	ReloadKeystrokes() bool

	GetAction() *Action
	Marshal() (string, error)
	ShouldEmitSignalChanged() bool
	// contains filtered or unexported methods
}

type ShortcutManager

type ShortcutManager struct {
	ConflictingKeystrokes []*Keystroke
	EliminateConflictDone bool
	// contains filtered or unexported fields
}

func NewShortcutManager

func NewShortcutManager(conn *x.Conn, keySymbols *keysyms.KeySymbols, eventCb KeyEventFunc) *ShortcutManager

func (*ShortcutManager) Add

func (sm *ShortcutManager) Add(shortcut Shortcut)

func (*ShortcutManager) AddCustom

func (sm *ShortcutManager) AddCustom(csm *CustomShortcutManager)

func (*ShortcutManager) AddKWin

func (sm *ShortcutManager) AddKWin(wmObj wm.Wm)

func (*ShortcutManager) AddKWinForWayland

func (sm *ShortcutManager) AddKWinForWayland(wmObj wm.Wm)

func (*ShortcutManager) AddMedia

func (sm *ShortcutManager) AddMedia(gsettings *gio.Settings)

func (*ShortcutManager) AddMediaToKwin

func (sm *ShortcutManager) AddMediaToKwin(gsettings *gio.Settings, wmObj wm.Wm)

func (*ShortcutManager) AddShortcutKeystroke

func (sm *ShortcutManager) AddShortcutKeystroke(shortcut Shortcut, ks *Keystroke)

func (*ShortcutManager) AddSpecial

func (sm *ShortcutManager) AddSpecial()

func (*ShortcutManager) AddSpecialToKwin

func (sm *ShortcutManager) AddSpecialToKwin(wmObj wm.Wm)

func (*ShortcutManager) AddSystem

func (sm *ShortcutManager) AddSystem(gsettings, gsPlatform, gsEnable *gio.Settings, wmObj wm.Wm)

func (*ShortcutManager) AddSystemById

func (sm *ShortcutManager) AddSystemById(gsettings *gio.Settings, id string)

func (*ShortcutManager) AddSystemToKwin

func (sm *ShortcutManager) AddSystemToKwin(gsettings *gio.Settings, wmObj wm.Wm)

func (*ShortcutManager) AddWM

func (sm *ShortcutManager) AddWM(gsettings *gio.Settings)

func (*ShortcutManager) CheckSystem

func (sm *ShortcutManager) CheckSystem(gsPlatform, gsEnable *gio.Settings, id string) bool

检测一个系统快捷键是否配置为可用,true可用,false不可用

func (*ShortcutManager) DelSystemById

func (sm *ShortcutManager) DelSystemById(id string)

func (*ShortcutManager) Delete

func (sm *ShortcutManager) Delete(shortcut Shortcut)

func (*ShortcutManager) DeleteShortcutKeystroke

func (sm *ShortcutManager) DeleteShortcutKeystroke(shortcut Shortcut, ks *Keystroke)

func (*ShortcutManager) Destroy

func (sm *ShortcutManager) Destroy()

func (*ShortcutManager) EnableRecord

func (sm *ShortcutManager) EnableRecord(val bool)

func (*ShortcutManager) EventLoop

func (sm *ShortcutManager) EventLoop()

func (*ShortcutManager) FindConflictingKeystroke

func (sm *ShortcutManager) FindConflictingKeystroke(ks *Keystroke) (*Keystroke, error)

ret0: Conflicting keystroke ret1: error

func (*ShortcutManager) GetByIdType

func (sm *ShortcutManager) GetByIdType(id string, type0 int32) Shortcut

func (*ShortcutManager) GetByUid

func (sm *ShortcutManager) GetByUid(uid string) Shortcut

func (*ShortcutManager) GrabAll

func (sm *ShortcutManager) GrabAll()

func (*ShortcutManager) List

func (sm *ShortcutManager) List() (list []Shortcut)

func (*ShortcutManager) ListByType

func (sm *ShortcutManager) ListByType(type0 int32) (list []Shortcut)

func (*ShortcutManager) ModifyShortcutKeystrokes

func (sm *ShortcutManager) ModifyShortcutKeystrokes(shortcut Shortcut, newVal []*Keystroke)

func (*ShortcutManager) NotifyLayoutChanged

func (sm *ShortcutManager) NotifyLayoutChanged()

func (*ShortcutManager) ReloadAllShortcutsKeystrokes

func (sm *ShortcutManager) ReloadAllShortcutsKeystrokes() []Shortcut

func (*ShortcutManager) Search

func (sm *ShortcutManager) Search(query string) (list []Shortcut)

func (*ShortcutManager) SetAllModKeysReleasedCallback

func (sm *ShortcutManager) SetAllModKeysReleasedCallback(cb func())

func (*ShortcutManager) UngrabAll

func (sm *ShortcutManager) UngrabAll()

type SystemShortcut

type SystemShortcut struct {
	*GSettingsShortcut
	// contains filtered or unexported fields
}

func (*SystemShortcut) GetAction

func (ss *SystemShortcut) GetAction() *Action

func (*SystemShortcut) SetAction

func (ss *SystemShortcut) SetAction(newAction *Action) error

func (*SystemShortcut) SetName

func (ss *SystemShortcut) SetName(name string) error

type XRecordEventHandler

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

func NewXRecordEventHandler

func NewXRecordEventHandler(keySymbols *keysyms.KeySymbols) *XRecordEventHandler

Jump to

Keyboard shortcuts

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