Runtime configuration and invocation

Startup: runtime configuration

On start, fgwirc loads and executes the action script $HOME/.fgwirc.rc (if $HOME is defined and non-empty and the file is readable). The name of the rc file can be overridden by using the -c command line argument. This script is also called the rc script, and it is a user provided. It is generic script and can run any action; but normally, as a matter of practice, it is responsible for:

Runtime configuration settings

Configuration settings are key-type-value triplets managed by the core of fgwirc. The rc script normally uses the set action (command) to change a setting. It should set at least irc_ident and irc_nick

Keyboard bindings

By default, fgwirc does not have hotkey bindings but is controlled by entering action commands (lines starting with a slash). Scripts can bind hotkeys to actions - already existing actions or to actions newly defined as script functions.

Most of the key bindings will use carefully crafted arguments with an already existing action. A good example on this is:

bind pad 53 "scroll -12"

which will make the page up key execute the scroll action with argument -12, scrolling the currently active window up by 12 lines.

Note: the same command line can be entered in the line editor in interactive UI mode, but has to be prefixed with a slash: slash prefixed lines are executed as actions. The same action can also be ran as a function call from any other scripting language, for example from a typical procedural language (e.g. awk) the same line would be:

bind("pad", 53, "scroll -12");

Such awk scripts can be loaded from the action script using the load action.

Example ~/.fgwirc.rc file

# configure default values; at least ident and nick so we can connect to an
# IRC server
set irc_ident jdoe
set irc_nick JohnDoe

# some real basic, static key bindings for the command-key/meta-mode (ctrl+X),
# window redraw (strl+L), scroll up/down (page up, page down) and toggle
# timestamps (meta+D)
bind ctrl 24 input_meta
bind ctrl 12 "window redraw"
bind pad 53 "scroll -12"
bind pad 54 "scroll +12"
bind meta 100 "toggle win_display_timestamp"

# Load a fawk script that creates keyboard bindings for switching to
# numbered windows, mostly using for loops; you can copy this script from src/
load winkey ~/.fgwirc/winkey.fawk fawk

# Some random UI improvements; you can copy this script from src/
load ui ~/.fgwirc/fgwirc_ui.fawk fawk

# The default window/server/channel layout (action script)
load channels ~/.fgwirc/channels act

Setting up the default server/window/channel assignment

The typical sequence of action calls for setting up a window is:

  1. win show W (to activate window number W, W is an integer)
  2. either server S/hostname (to create a new server connection with identifier S, S is an integer)
  3. ...or win server S (to associate the window to an existing server connection)

For the server action, the currently active (last shown) window will become the server's own status window. For other windows, once win server... was used to associate the window with a server, a join action will make fgwirc try to join a channel.

Loading optional user scripts

load action.can be used to load further user scripts recursively. The rc script needs to be an action script, but further user scripts can be in any scripting language supported by fungw.

Note: action scripts can not have branches, loops, variables and can not define new actions, but using any other scripting language can.

Example ~/.fgwirc/channels file


# announce the script
echo My default channel setup

# create 25 new windows
win new*25

# switch to window 1 and connect to irc.repo.hu and make it irc server 1
# window 1 will be the server message window for irc.repo.hu
# also turn on logging
win show 1
win log on ~/.fgwirc/LOG.repo
server 1/irc.repo.hu

# switch to window 2, turn on logging, assign the window to irc server 1
# and join to #dev there
win show 2
win log on LOG.#dev
win server 1
join #dev

# ... more servers and more channels assigned to different windows