ot-snippet-002.sh requires bash shell version 4 or newer. The main functionality - return expanded snippets - works even with a plain console environment.
Using some advanced features of ot-snippet requires a desktop environment to be able to open new windows windows like a terminal emulator, or to show a zenity-based dialog.
Following terminal applications have been tested (but others should work as well):
The ot-snippet --sel feature requires zenity to be available/installed (zentity is preinstalled with mint 20.x).
Nice to have - extend $PATH
You can skip this section, if you prefer to use ot-snippet with a full qualified path from your IRC-client, or already have setup a local folder to be covered by the $PATH environment variable.
For an easier usage of local scripts at the xsession you should setup a local folder: $HOME/bin
# create ~/bin to keep local executables there mkdir ~/bin
With an ubuntu based version of linux mint, an existing folder ($HOME/bin) will be added automatically to $PATH on login by lightdm.
If you are using a distribution, which doesn't add $HOME/bin automatically, you have to adjust/create either ~/.xsessionrc (in case you are using a desktop manager (DM) with your setup) or ~/.xinitrc (in case you are using a setup without a DM) to add and export your prefered folder(s) to the $PATH environment of the xsession.
You can use this as a blueprint accordingly:
# ~/.xsessionrc - startup script (used with an active DM) # for setups without a DM - use this file as ~/.xinitrc # ---------------------------------------------------------------------------- # extend the PATH by existing folder(s) below $HOME # orcus 2022-01-18 # add/change folders according to your needs for p in "bin" ".local/bin"; do ap="$HOME/$p" # only add if respective folder exists if [ -d "$ap" ]; then # and isn't already part of PATH if [[ "$PATH" != *"$ap"* ]]; then export PATH="$ap:$PATH" fi fi done
You have to logout/login to get the modification into effect.
To be able to use the --sel option (suggested), zenity has to be available/installed.
Install zenity at debian/ubuntu based linux:
# install zentiy at debian/ubuntu based linux sudo apt-get install zenity
... centos/fedora based linux:
# install zentiy at centos/fedora based linux sudo yum install zenity
... arch based linux:
# install zentiy at arch based linux sudo pacman -S zenity
# skip next 2 lines if you don't plan do use a ~/bin folder if [ -d ~/bin ]; then echo "create missing ~/bin"; mkdir ~/bin; fi cd ~/bin # if you are not using/having a ~/bin folder, just cd into your prefered # directory instead: # download the current ot-snippet-version and make it executable wget https://www.orcus.de/Entities/linux/ot-snippet-002.sh -O ot-snippet-002.sh chmod +x ot-snippet-002.sh # add symbolic links - for details see: # https://www.orcus.de/main_support/ot-snippet/symbolic-links.htm ln -s ot-snippet-002.sh ot-snippet-strm ln -s ot-snippet-002.sh ot-snippet-para
If your used directory is part of $PATH you could just run the first command(s) from a terminal to check things are working as expected- which should show something like this:
ot-snippet-para hi Welcome to the official linuxmint support channel - if you need support: describe your issue + used mint version: 19.x, 20.x, lmde4 ? + desktop environment: cinnamon, mate, xfce ?; stay connected afterwards == people need some time to answer... Use /join #linuxmint-chat for general/non-support chat ... - many people are there too ot-snippet-para ask guest7235 guest7235> If you need support - describe your issue, giving some (more) details + version used: mint 19.x,20.x, lmde4 ? + DE: cinnamon, mate, xfce? - if anybody has an answer she/he will reply. guest7235> Stay connected afterwards == people need some time to answer....
Upgrade 001 to 002
Users of ot-snippet version 001, who edited snippets at ot-snippet.sh directly, can use ot-snippet.sh --new-custom to create a custom-file containing an extract of the snippets.
The V001 custom file will be named ot-snippet.txt initially and has to be renamed to ot-snippet-strm.txt and/or ot-snippet-para.txt to match the according symbolic link(s) of the 002 version.
If ot-snippet detects accordingly named custom files, residing next to 'their' matching symbolic links, it will use the snippet definitions of the custom files instead of its own/internal definitions.
setup IRC clients
Using ot-snippet from IRC clients only requires them to support some form of the /exec command - which most will.
If you didn't place ot-snippet at some location covered by the $PATH environment variable, you have to use the full qualified path of ot-snippet to call it.
Using the stream variant of ot-snippet requires it to be named like ot-snippet-strm (see stream mode links for details).
Hexchat has an unexpected behavior if you are editing config settings using its dialogs: If you change a value at an input field, you have either to press Enter (to quit editing) or set the focus to another dialog element before using OK or Save buttons, as otherwise hexchat wont notice updated/new values and stores the old/empty value instead.
Hexchat isn't case sensitive with user defined command names - so you are fine using either form to call the user command, later on.
adding the user command(s)
To add a new user command at hexchat open menu: Settings -> User commands
At the shown dialog press the Add button, which will add a new empty line.
[enlarge via mouse-click]
Click into the left column and define the name of the new user-command - using something short there as you will use it a lot over the day - using here S (like snippet / stream mode).
Click into the right column to enter the actual command there and press Enter to finish/end the edit. To use the suggested stream mode with ot-snippet you have to add two lines, where the order of the entered command definitions is important. Although the parameter mode is deprecated and should be avoided, you could add another user command - giving it a different name P (like pattern/parameter mode):
|S||exec -o ot-snippet-strm|
|P||exec -o ot-snippet-para &2|
Finish editing by pressing Enter or setting the focus to some different input field. After that use the Save button to save your changes and close the dialog.
Instead of using the hexchat gui one could edit the underlying config file ~/.config/hexchat/commands.conf manually - appending commands at the end of the file. You have to add an empyt line ahead of a new command at the file - the result should look similar to that (leading lines are stripped away):
NAME WII CMD quote WHOIS %2 %2 NAME S CMD exec -o ot-snippet-strm NAME S CMD execwrite &2 NAME P CMD exec -o ot-snippet-para &2
With current installs of weechat the exec plugin should be available out of the box; in case its missing with your setup, you have to install it using (debian/ubuntu):
# debian/ubuntu based sudo apt-get install weechat-plugins
... centos/fedora based linux:
# install weechat-plugins at centos/fedora based linux sudo yum install weechat-plugins
... arch based linux:
# install weechat-plugins at arch based linux sudo pacman -S weechat-plugins
To use ot-snippet you should define an alias for it - to use the suggested stream-mode, its:
/alias add s exec -o -name ots -stdin ot-snippet-strm; exec -in ots $1-
To define an alias for the deprecated parameter mode of ot-snippet, use:
/alias add p exec -o ot-snippet-para $1-
floodprotection - rate limiter
You might want to adjust the rate limiter of weechat to some other value than the default 2 seconds. example: if you did add spotchat as your network, you could check for the currently used value:
To set it to 1 second use:
/set irc.server.spotchat.anti_flood_prio_high 1
And to turn it off entirely use:
/set irc.server.spotchat.anti_flood_prio_high 0
The predefined snippets are using typically max 3 lines of text and should be ok with flood protection at most irc networks/channels; if you face issues because of 'flooding' you either got to shorten snippets to fall below the according limits or raise the rate-limiter of weechat (again).