summaryrefslogtreecommitdiff
path: root/doc/it/autogen/user/trigger_commands.adoc
blob: 006221753fe366657aa49db023ba85e62a85711b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// This file is auto-generated by script docgen.py.
// DO NOT EDIT BY HAND!
//
[[command_trigger_trigger]]
* `+trigger+`: manage triggers, the Swiss Army knife for WeeChat

----
/trigger  list|listfull|listdefault
          add|addoff|addreplace <name> <hook> ["<arguments>" ["<conditions>" ["<regex>" ["<command>" ["<return_code>" ["<post_action>"]]]]]]
          addinput [<hook>]
          input|output|recreate <name>
          set <name> <option> <value>
          rename|copy <name> <new_name>
          enable|disable|toggle [<name>|-all [<name>...]]
          restart <name>|-all [<name>...]
          show <name>
          del <name>|-all [<name>...]
          restore <name> [<name>...]
          default -yes
          monitor [<filter>]

       list: list triggers (without argument, this list is displayed)
   listfull: list triggers with detailed info for each trigger
listdefault: list default triggers
        add: add a trigger
     addoff: add a trigger (disabled)
 addreplace: add or replace an existing trigger
       name: name of trigger
       hook: signal, hsignal, modifier, print, command, command_run, timer, config, focus
  arguments: arguments for the hook, depending on hook (separated by semicolons):
             signal: name(s) of signal (required)
             hsignal: name(s) of hsignal (required)
             modifier: name(s) of modifier (required)
             print: buffer, tags, message, strip colors
             command: command (required), description, arguments, description of arguments, completion
             command_run: command(s) (required)
             timer: interval (required), align on second, max calls
             config: name(s) of option (required)
             focus: name(s) of area (required)
 conditions: evaluated conditions for the trigger
      regex: one or more regular expressions to replace strings in variables
    command: command to execute (many commands can be separated by ";"
return_code: return code in callback (ok (default), ok_eat, error)
post_action: action to take after execution (none (default), disable, delete)
   addinput: set input with default arguments to create a trigger
      input: set input with the command used to create the trigger
     output: send the command to create the trigger on the buffer
   recreate: same as "input", with option "addreplace" instead of "add"
        set: set an option in a trigger
     option: name of option: name, hook, arguments, conditions, regex, command, return_code
             (for help on option, you can type: /help trigger.trigger.<name>.<option>)
      value: new value for the option
     rename: rename a trigger
       copy: copy a trigger
     enable: enable trigger(s) (without arguments: enable triggers globally)
    disable: disable trigger(s) (without arguments: disable triggers globally)
     toggle: toggle trigger(s) (without arguments: toggle triggers globally)
    restart: restart trigger(s) (recreate the hooks)
       show: show detailed info on a trigger (with some stats)
        del: delete a trigger
       -all: do action on all triggers
    restore: restore trigger(s) with the default values (works only for default triggers)
    default: delete all triggers and restore default ones
    monitor: open the trigger monitor buffer, with optional filter:
     filter: filter hooks/triggers to display (a hook must start with "@", for example "@signal"), many filters can be separated by commas; wildcard "*" is allowed in each trigger name

When a trigger callback is called, following actions are performed, in this order:
  1. check conditions; if false, exit
  2. replace text using POSIX extended regular expression(s) (if defined in trigger)
  3. execute command(s) (if defined in trigger)
  4. exit with a return code (except for modifiers and focus)
  5. perform post action

Examples (you can also look at default triggers with /trigger listdefault):
  add text attributes *bold*, _underline_ and /italic/ (only in user messages):
    /trigger add effects modifier weechat_print "${tg_tag_nick}" "==\*(\S+)\*==*${color:bold}${re:1}${color:-bold}*== ==_(\S+)_==_${color:underline}${re:1}${color:-underline}_== ==/(\S+)/==/${color:italic}${re:1}${color:-italic}/"
  hide nicklist bar on small terminals:
    /trigger add resize_small signal signal_sigwinch "${info:term_width} < 100" "" "/bar hide nicklist"
    /trigger add resize_big signal signal_sigwinch "${info:term_width} >= 100" "" "/bar show nicklist"
  silently save config each hour:
    /trigger add cfgsave timer 3600000;0;0 "" "" "/mute /save"
  open trigger monitor and show only modifiers and triggers whose name starts with "resize":
    /trigger monitor @modifier,resize*
----