1
0
Fork
You've already forked favlinks
0
Manage atlernatives per user the simple way
  • Makefile 100%
2025年11月25日 10:24:46 +01:00
.gitignore chore: end of files and using env for shebang 2025年11月07日 16:14:36 +01:00
COPYING added license 2024年01月21日 00:52:34 +01:00
favlinks.in add verbose option 2025年11月25日 10:24:46 +01:00
Makefile chore: end of files and using env for shebang 2025年11月07日 16:14:36 +01:00
README.md doc: added build info 2025年11月07日 16:13:44 +01:00

favlinks - simple alternative to alternatives

On a lean system I still want to enable some preferred programs, and managing them all easily.

favlinks is a simple (posix) shell script that reads a configuration file and create links to preferred programs when ran. It does not handle associated man pages and so on.

A global configuration is available (even needed) and by default set to /etc/default/favlinks (can be customized on install). Additionnally users can set their own preferences through a user configuration file set by default to $XDG_CONFIG_HOME/favlinks.

Target program might change and favlinks can detect it, recreating the updated link. Also, if a link name points to something else than a link, nothing is changed to avoid overriding programs and scripts.

Build

make

You can alter the generation with make variables:

Variable Default Description
DESTDIR /usr/local Usual, prefix
OUTNAME favlinks give it a new name (script and configuration file)
DESTSHELL sh dash for example
SYSCONFDIR /etc/default global configuration file location
SYSBINDIR $(DESTDIR)/bin where favlinks and global links will be put
USRCONFDIR $XDG_CONFIG_HOME user configuration file location location
USRBINDIR $XDG_BIN_HOME where user links will be put

Example:

make DESTDIR=/usr OUTNAME=alternatives DESTSHELL=dash SYSCONFDIR=/etc/conf.d all

Configuration format

Pretty simple and common: blank lines and those starting with # are ignored. Other lines must be equal (=) separated pairs (like variables assignment) giving the resulting program for a link name, like:

term=/usr/bin/urxvt
sensible-terminal=term

By default links are created in user bin directory ($XDG_BIN_HOME by default), but with root access, they can be set globally with the -g argument: favlinks -g. They will be created in the same directory than favlinks (/usr/local/bin by default).

Sample usage

Let's think of a system with 2 users, all using the same link names:

  • term for terminal emulator
  • www for internet browser
  • fm for file manager
  • pic for pictures viewer

Due to installed packages, default settings in /etc/default/favlinks are:

# default links
term=/usr/bin/urxvt
www=/usr/bin/firefox
fm=/usr/bin/pcmanfm
pic=/usr/bin/gpicview
sensible-brower=www
sensible-terminal=term

In /etc/profile.d/favlinks.sh we call the script to create/update global links:

/usr/local/bin/favlinks -g

Then user1 can optionnally run favlinks in his/hers session startup without own settings, creating all the same links in $XDG_BIN_HOME than in /usr/local/bin, just in case someday own preferences change.

user2 prefers to use nsxiv to view pictures so its overriding settings in $XDG_CONFIG_HOME/favlinks contains:

pic=/usr/bin/nsxiv

And calls favlinks in his/her session startup. Thus, favlinks will create or update all links in $XDG_BIN_HOME if needed.