Documentation ¶
Index ¶
- Constants
- func CleanClipboard(menu *Menu, text string)
- func CopyToClipboard(menu *Menu, text string) error
- func CreateOTP(a gokeepasslib.Entry, time int64) (otp string, err 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 ConfigurationExecutable
- type ConfigurationGeneral
- type ConfigurationStyle
- type Database
- type Entry
- type ErrParseConfiguration
- type ErrorDatabase
- type ErrorPrompt
- type Flags
- type Menu
- type MenuSelection
- type OTPAuth
- type OTPError
- type Packet
Constants ¶
const ( PromptRofi = "rofi" PromptWofi = "wofi" PromptCustom = "custom" )
Menu tools used for prompts
const ( ClipboardToolXsel = "xsel" ClipboardToolWlclipboard = "wl-clipboard" ClipboardToolCustom = "custom" )
Clipboard tools used for clipboard manager
const ( OTP = "otp" TOTPSEED = "TOTP Seed" TOTPSETTINGS = "TOTP Settings" TOTP = "totp" OTPAUTH = "otpauth" )
OTP constants
const ( MenuShow = MenuSelection(iota) // Show entries MenuReload // Reload database MenuExit // Exit )
MenuSelections enum values
const Version = "1.4.0"
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 CreateOTP ¶ added in v1.4.0
CreateOTP generates a time-sensitive TOTP code for a database entry.
Modern versions of KeepassXC and Keepass2Android store this URL in the `otp` key. A historic version stored data ds:
TOTP Seed = SECRET TOTP Settings = PERIOD;DIGITS
If the `otp` key exists, it should be used and the TOTP values ignored; otherwise, the legacy values can be used.
entry is the DB entry for which to generate a code; time is the Unix time to generate for the code -- generally time.Now().Unix()
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 Executable ConfigurationExecutable 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 ConfigurationExecutable ¶ added in v1.3.0
type ConfigurationExecutable struct { CustomPromptPassword string // Custom executable for prompt password CustomPromptMenu string // Custom executable for prompt menu CustomPromptEntries string // Custom executable for prompt entries CustomPromptFields string // Custom executable for prompt fields CustomClipboardCopy string // Custom executable for clipboard copy CustomClipboardPaste string // Custom executable for clipboard paste CustomClipboardClean string // Custom executable for clipboard clean }
ConfigurationExecutable is the sub-structure of the configuration related to tools executed by kpmenu
type ConfigurationGeneral ¶
type ConfigurationGeneral struct { Menu string // Which menu to use 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 NoOTP bool // Flag to do not handle OTPs }
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 ¶
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
type OTPAuth ¶ added in v1.4.0
type OTPAuth struct { Type string Account string Issuer string Period int Digits int // contains filtered or unexported fields }
OTPAuth supports only TOTP (at the moment)