mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 06:54:58 +02:00
Implement support for buttons on notifications in Linux
This commit is contained in:
@@ -102,6 +102,9 @@ func (p *parsed_data) generate_chunks(callback func(string)) {
|
||||
if len(p.image_data) > 0 {
|
||||
add_payload("icon", utils.UnsafeBytesToString(p.image_data))
|
||||
}
|
||||
if len(p.opts.Button) > 0 {
|
||||
add_payload("buttons", strings.Join(p.opts.Button, "\u2028"))
|
||||
}
|
||||
write_chunk(";")
|
||||
}
|
||||
|
||||
@@ -110,7 +113,7 @@ func (p *parsed_data) run_loop() (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
activated := ""
|
||||
activated := -1
|
||||
prefix := ESC_CODE_PREFIX + "i=" + p.identifier
|
||||
|
||||
poll_for_close := func() {
|
||||
@@ -156,7 +159,9 @@ func (p *parsed_data) run_loop() (err error) {
|
||||
lp.Quit(0)
|
||||
}
|
||||
case "":
|
||||
activated = utils.IfElse(payload == "", "activated", payload)
|
||||
if activated, err = strconv.Atoi(utils.IfElse(payload == "", "0", payload)); err != nil {
|
||||
return fmt.Errorf("Got invalid activation response from terminal: %#v", payload)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,7 +197,7 @@ func (p *parsed_data) run_loop() (err error) {
|
||||
lp.KillIfSignalled()
|
||||
return
|
||||
}
|
||||
if activated != "" && err == nil {
|
||||
if activated > -1 && err == nil {
|
||||
fmt.Println(activated)
|
||||
}
|
||||
return
|
||||
|
||||
@@ -26,6 +26,13 @@ default=kitten-notify
|
||||
The application name for the notification.
|
||||
|
||||
|
||||
--button -b
|
||||
type=list
|
||||
Add a button with the specified text to the notification. Can be specified multiple times for multiple buttons.
|
||||
If --wait-for-completion is used then the kitten will print th ebutton number to STDOUT if the user clicks a button.
|
||||
1 for the first button, 2 for the second button and so on.
|
||||
|
||||
|
||||
--urgency -u
|
||||
default=normal
|
||||
choices=normal,low,critical
|
||||
@@ -62,7 +69,7 @@ your own identifier via the --identifier option.
|
||||
--wait-till-closed -w
|
||||
type=bool-set
|
||||
Wait until the notification is closed. If the user activates the notification,
|
||||
"activated" is printed to STDOUT before quitting. Press the Esc or Ctrl+C keys
|
||||
"0" is printed to STDOUT before quitting. Press the Esc or Ctrl+C keys
|
||||
to close the notification manually.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user