Closed jjakob closed 1 year ago
The order of preference is GOMUKS_*_HOME
> GOMUKS_ROOT
> system default (XDG)
Ah, I see that now, so it could be:
alias gomuksaccount1='name=account1 GOMUKS_ROOT="~/.gomuks_$name" DEBUG_DIR="/tmp/gomuks_$name" GOMUKS_DOWNLOAD_HOME="~/.gomuks_$name/downloads" gomuks'
DEBUG_DIR still needs to be set separately, and optionally GOMUKS_DOWNLOAD_HOME.
I have a quick shell function to do something similar. As long as the config file is created and the other dirs are listed there, all you need is GOMUKS_CONFIG_HOME
.
This still needs to actually setup a new account if one's not listed and adding completion for homeservers is pending, but something like this works well, especially if you have many different accounts where it'd be a hassle to constantly make multiple aliases for each.
(edited to include account setup/deletion, debug dir, etc)
function mx
function call_help
printf "Usage: mx <HOMESERVER> [OPTIONS]\n\n"
printf " HOMESERVER The name assigned to a Matrix homeserver\n\n"
printf "Options:\n"
printf " -h/--help Prints help and exits\n"
printf " --create Creates a new homeserver configuration\n"
printf " --delete Deletes the homeserver configuration"
end
set -l options (fish_opt --short=h --long=help)
set options $options (fish_opt --short=c --long=create --optional-val --long-only)
set options $options (fish_opt --short=d --long=delete --optional-val --long-only)
if test -z "$argv"
call_help
return 0
end
argparse -x 'create,delete' $options -- $argv
or return
set homeserver $argv[1]
set config ~/.config/gomuks/$homeserver
if set -q _flag_help
call_help
return 0
end
if set -q _flag_create
if test -d $config
printf "Homeserver '$homeserver' already exists"
return 1
else
printf "Setting up $homeserver...\n"
mkdir $config
end
end
if set -q _flag_delete
if test -d $config
printf "Deleting homeserver '$homeserver'...\n"
rm -r \
$config \
~/.local/share/gomuks/$homeserver \
~/.cache/gomuks/$homeserver
return 0
else
printf "Homeserver '$homeserver' does not exist"
return 1
end
end
if test ! -d $config
printf "Homeserver '$homeserver' does not exist. Please create before proceeding"
return 1
else
set -x GOMUKS_CONFIG_HOME $config
set -x DEBUG_DIR /tmp/gomuks_$homeserver
gomuks
end
end
@ElDifinitivo Are you sure just setting GOMUKS_CONFIG_HOME is enough? You're still sharing cache, data, debug and download directories between the different processes, I don't think that's a good idea. Even if it works, you might want to completely delete all disk data for one homeserver, if you mix them it wouldn't be possible. Even if you set GOMUKSROOT which changes the location of all XDG dirs, it still shares the download directory and debug log file (see https://github.com/tulir/gomuks/issues/307) It is a good idea to have just one alias and use an env variable to change the directory names, I don't know why I didn't think of that.
@jjakob As long as the lines in your config point to different dirs (with the exception of download_dir
) then you're good. And yes like you said, it would be a good idea to pass a different debug dir, but separate download dirs don't seem necessary from my experience
data_dir: /home/<user>/.local/share/gomuks/<homserver>
cache_dir: /home/<user>/.cache/gomuks/<homserver>
history_path: /home/<user>/.cache/gomuks/<homserver>/history.db
room_list_path: /home/<user>/.cache/gomuks/<homserver>/rooms.gob.gz
media_dir: /home/<user>/.cache/gomuks/<homserver>/media
download_dir: /home/<user>/tmp
state_dir: /home/<user>/.cache/gomuks/<homserver>/state
This is what I use:
Using GOMUKSROOT doesn't seem like a good idea to me as it could get overriden bx the XDG env variables, since gomuks checks those first.
I also have this to proxy through tor:
and a combination of those can be made by replacing gomuks with tgomuks in the first alias.