Skip to content

Commit

Permalink
Allow custom nix-store command
Browse files Browse the repository at this point in the history
Also, limit Discord process names to 15 characters
  • Loading branch information
ObserverOfTime committed Mar 27, 2021
1 parent d4fb655 commit 2ec4f53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ You can then keep `betterdiscordctl` up to date with one command:

* `--nix`

Automatically detect the default Nix store directories for Discord.
Automatically detect the default Nix store directories for Discord. A given
option argument will be used as the nix-store command to call.

* `--upgrade-url` (default `https://git.io/bdctl`)

Expand Down
18 changes: 12 additions & 6 deletions betterdiscordctl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ xdg_config=${XDG_CONFIG_HOME:-$HOME/.config}
data=${XDG_DATA_HOME:-$HOME/.local/share}/betterdiscordctl
snap_bin=snap
flatpak_bin=flatpak
nix_bin='nix-store'

show_help() {
cat << EOF
Expand All @@ -42,22 +43,20 @@ Options:
-v, --verbose Increase verbosity
-s, --scan=DIRECTORIES Colon-separated list of directories to scan for
a Discord installation
(default '/opt:/usr/share')
-f, --flavors=FLAVORS Colon-separated list of Discord flavors
(default ':canary:ptb')
-d, --discord=DIRECTORY Use the specified Discord directory
(requires --modules)
-m, --modules=DIRECTORY Use the specified Discord modules directory
-r, --bd-repo=REPOSITORY Use the specified Git repo for BetterDiscord
--bd-repo-branch=BRANCH Use the specified Git branch for BetterDiscord
(default 'stable16')
-b, --betterdiscord=DIRECTORY Use the specified BetterDiscord directory
-c, --copy-bd Copy BD directory instead of symlinking
--snap[=COMMAND] Use the Snap version of Discord (optionally
using the specified snap command)
--flatpak[=COMMAND] Use the Flatpak version of Discord (optionally
using the specified flatpak command)
--nix Look for Discord in the nix store
--nix[=COMMAND] Look for Discord in the nix store (optionally
using the specified nix-store command)
--upgrade-url=URL Custom URL to upgrade betterdiscordctl with
Commands:
Expand Down Expand Up @@ -209,6 +208,13 @@ while :; do
--nix)
nix=yes
;;
--nix=?*)
nix=yes
nix_bin=${1#*=}
;;
--nix=)
die_non_empty '--nix'
;;
--upgrade-url)
if [[ ${2+x} ]]; then upgrade_url=$2; shift
else die_non_empty '--upgrade-url'; fi
Expand Down Expand Up @@ -480,7 +486,7 @@ bdc_nix() {
elif [[ ${flavor,,} == canary ]]; then
flavor=Canary
fi
scandir=$(nix-store -r "$(which "Discord$flavor")")
scandir=$("$nix_bin" -r "$(which "Discord$flavor")")
verbose 2 "VV: Scanning $scandir"
discord="$scandir/opt/Discord$flavor"
if [[ -d $discord ]]; then
Expand All @@ -506,7 +512,7 @@ bdc_kill() {
declare process_name=Discord
[[ $flavor ]] && process_name+=" $flavor"
printf 'Killing %s processes...\n' "$process_name" >&2
pkill -exi -KILL "discord-?$flavor" || printf 'No active processes found.\n' >&2
pkill -exi -KILL "discord${flavor:0:8}" || printf 'No active processes found.\n' >&2
}
bd_injector() {
Expand Down

0 comments on commit 2ec4f53

Please sign in to comment.