Documentation
¶
Index ¶
- Constants
- func CleanClipboard(menu *Menu, text string)
- func CopyToClipboard(menu *Menu, text string) error
- func Execute(menu *Menu) bool
- func GetClipboard(menu *Menu) (string, error)
- func PromptEntries(menu *Menu) (*Entry, ErrorPrompt)
- func PromptMenu(menu *Menu) (MenuSelection, ErrorPrompt)
- func Show(menu *Menu) bool
- func StartClient() error
- func StartServer(m *Menu) (err error)
- type Configuration
- type ConfigurationDatabase
- type ConfigurationGeneral
- type ConfigurationStyle
- type Database
- type Entry
- type ErrParseConfiguration
- type ErrorDatabase
- type ErrorPrompt
- type Flags
- type Menu
- type MenuSelection
- type Packet
Constants ¶
const ( ClipboardToolXsel = "xsel" ClipboardToolWlclipboard = "wl-clipboard" )
Clipboard tool to use for clipboard manager
const ( MenuShow = MenuSelection(iota) // Show entries MenuReload // Reload database MenuExit // Exit )
MenuSelections enum values
const Version = "1.2.1"
Version is the version of kpmenu
Variables ¶
This section is empty.
Functions ¶
func CleanClipboard ¶
CleanClipboard cleans the clipboard, if not changed
func CopyToClipboard ¶
CopyToClipboard copies text into the clipboar
func Execute ¶
Execute is the function used to open the database (if necessary) and open the menu returns true if the program should exit
func GetClipboard ¶
GetClipboard gets the current clipboard
func PromptEntries ¶
func PromptEntries(menu *Menu) (*Entry, ErrorPrompt)
PromptEntries executes dmenu to ask for an entry selection Returns the selected entry
func PromptMenu ¶
func PromptMenu(menu *Menu) (MenuSelection, ErrorPrompt)
PromptMenu executes dmenu to ask for menu selection Returns the MenuSelection chosen
func Show ¶
Show checks if the database configuration is changed, if so it will re-open the database returns true if the program should exit
func StartServer ¶
StartServer starts to listen for client packets
Types ¶
type Configuration ¶
type Configuration struct {
General ConfigurationGeneral
Style ConfigurationStyle
Database ConfigurationDatabase
Flags Flags
}
Configuration is the main structure of kpmenu config
func NewConfiguration ¶
func NewConfiguration() *Configuration
NewConfiguration initializes a new Configuration pointer
func (*Configuration) InitializeFlags ¶
func (c *Configuration) InitializeFlags()
InitializeFlags prepare cli flags
func (*Configuration) LoadConfig ¶
func (c *Configuration) LoadConfig() error
LoadConfig loads the configuration into Configuration
func (*Configuration) ParseFlags ¶
func (c *Configuration) ParseFlags(args []string)
ParseFlags parses cli flags with given arguments
type ConfigurationDatabase ¶
type ConfigurationDatabase struct {
Database string
KeyFile string
Password string
FieldOrder string
FillOtherFields bool
FillBlacklist string
}
ConfigurationDatabase is the sub-structure of the configuration related to database settings
type ConfigurationGeneral ¶
type ConfigurationGeneral struct {
UseRofi bool // Use Rofi instead of dmenu
ClipboardTool string // Clipboard tool to use
ClipboardTimeout int // Clipboard timeout before clean it
NoCache bool // Flag to do not cache master password
CacheOneTime bool // Cache the password only the first time you write it
CacheTimeout int // Timeout of cache
ShowNotifications bool // Flag for showing desktop notifications
DoNotShowMenu bool // Flag for skipping the menu selection
RememberLastEntry bool // Remember last selected entry
ArgsSeparator string // Separator char for custom args
}
ConfigurationGeneral is the sub-structure of the configuration related to general kpmenu settings
type ConfigurationStyle ¶
type ConfigurationStyle struct {
PasswordBackground string
TextPassword string
TextMenu string
TextEntry string
TextField string
FormatEntry string
ArgsPassword string
ArgsMenu string
ArgsEntry string
ArgsField string
}
ConfigurationStyle is the sub-structure of the configuration related to style of dmenu
type Database ¶
type Database struct {
Loaded bool
Keepass *gokeepasslib.Database
Entries []Entry
}
Database contains the KeePass database and its entry list
func (*Database) AddCredentialsToDatabase ¶
func (db *Database) AddCredentialsToDatabase(cfg *Configuration, password string)
AddCredentialsToDatabase adds credentials into gokeepasslib credentials struct
func (*Database) IterateDatabase ¶
func (db *Database) IterateDatabase()
IterateDatabase iterates the database and makes a list of entries
func (*Database) OpenDatabase ¶
func (db *Database) OpenDatabase(cfg *Configuration) error
OpenDatabase decodes the database with the given configuration
type Entry ¶
type Entry struct {
UUID gokeepasslib.UUID
FullEntry gokeepasslib.Entry
}
Entry is a container for keepass entry
type ErrParseConfiguration ¶
ErrParseConfiguration is the error return if the configuration loading fails
func NewErrorParseConfiguration ¶
func NewErrorParseConfiguration(message string, err error) ErrParseConfiguration
NewErrorParseConfiguration initializes the error
func (ErrParseConfiguration) Error ¶
func (err ErrParseConfiguration) Error() string
type ErrorDatabase ¶
ErrorDatabase is an error that can be fatal or non-fatal
func NewErrorDatabase ¶
func NewErrorDatabase(message string, err error, fatal bool) *ErrorDatabase
NewErrorDatabase makes an ErrorDatabase
func (*ErrorDatabase) String ¶
func (err *ErrorDatabase) String() string
type ErrorPrompt ¶
ErrorPrompt is a structure that handle an error of dmenu/rofi
func PromptFields ¶
func PromptFields(menu *Menu, entry *Entry) (string, ErrorPrompt)
PromptFields executes dmenu to ask for a field selection Returns the selected field value as string
func PromptPassword ¶
func PromptPassword(menu *Menu) (string, ErrorPrompt)
PromptPassword executes dmenu to ask for database password Returns the written password
type Flags ¶
Flags is the sub-structure of the configuration used to handle flags that aren't into the config file
type Menu ¶
type Menu struct {
CacheStart time.Time // Cache start time
CliArguments []string // Arguments of kpmenu
Configuration *Configuration // Configuration of kpmenu
Database *Database // Database
WaitGroup *sync.WaitGroup // WaitGroup used for goroutines
}
Menu is the main structure of kpmenu
func Initialize ¶
func Initialize() *Menu
Initialize is the function that initialize a menu, handle config and parse cli arguments
func (*Menu) OpenDatabase ¶
func (m *Menu) OpenDatabase() *ErrorDatabase
OpenDatabase asks for password and populates the database
func (*Menu) OpenMenu ¶
func (m *Menu) OpenMenu() *ErrorDatabase
OpenMenu executes dmenu to interface the user with the database
type MenuSelection ¶
type MenuSelection int
MenuSelection is an enum used for prompt menu selection
func (MenuSelection) String ¶
func (el MenuSelection) String() string