Skip to content

Commit 2ec4f53

Browse files
Allow custom nix-store command
Also, limit Discord process names to 15 characters
1 parent d4fb655 commit 2ec4f53

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ You can then keep `betterdiscordctl` up to date with one command:
102102

103103
* `--nix`
104104

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

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

betterdiscordctl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ xdg_config=${XDG_CONFIG_HOME:-$HOME/.config}
3131
data=${XDG_DATA_HOME:-$HOME/.local/share}/betterdiscordctl
3232
snap_bin=snap
3333
flatpak_bin=flatpak
34+
nix_bin='nix-store'
3435

3536
show_help() {
3637
cat << EOF
@@ -42,22 +43,20 @@ Options:
4243
-v, --verbose Increase verbosity
4344
-s, --scan=DIRECTORIES Colon-separated list of directories to scan for
4445
a Discord installation
45-
(default '/opt:/usr/share')
4646
-f, --flavors=FLAVORS Colon-separated list of Discord flavors
47-
(default ':canary:ptb')
4847
-d, --discord=DIRECTORY Use the specified Discord directory
4948
(requires --modules)
5049
-m, --modules=DIRECTORY Use the specified Discord modules directory
5150
-r, --bd-repo=REPOSITORY Use the specified Git repo for BetterDiscord
5251
--bd-repo-branch=BRANCH Use the specified Git branch for BetterDiscord
53-
(default 'stable16')
5452
-b, --betterdiscord=DIRECTORY Use the specified BetterDiscord directory
5553
-c, --copy-bd Copy BD directory instead of symlinking
5654
--snap[=COMMAND] Use the Snap version of Discord (optionally
5755
using the specified snap command)
5856
--flatpak[=COMMAND] Use the Flatpak version of Discord (optionally
5957
using the specified flatpak command)
60-
--nix Look for Discord in the nix store
58+
--nix[=COMMAND] Look for Discord in the nix store (optionally
59+
using the specified nix-store command)
6160
--upgrade-url=URL Custom URL to upgrade betterdiscordctl with
6261
6362
Commands:
@@ -209,6 +208,13 @@ while :; do
209208
--nix)
210209
nix=yes
211210
;;
211+
--nix=?*)
212+
nix=yes
213+
nix_bin=${1#*=}
214+
;;
215+
--nix=)
216+
die_non_empty '--nix'
217+
;;
212218
--upgrade-url)
213219
if [[ ${2+x} ]]; then upgrade_url=$2; shift
214220
else die_non_empty '--upgrade-url'; fi
@@ -480,7 +486,7 @@ bdc_nix() {
480486
elif [[ ${flavor,,} == canary ]]; then
481487
flavor=Canary
482488
fi
483-
scandir=$(nix-store -r "$(which "Discord$flavor")")
489+
scandir=$("$nix_bin" -r "$(which "Discord$flavor")")
484490
verbose 2 "VV: Scanning $scandir"
485491
discord="$scandir/opt/Discord$flavor"
486492
if [[ -d $discord ]]; then
@@ -506,7 +512,7 @@ bdc_kill() {
506512
declare process_name=Discord
507513
[[ $flavor ]] && process_name+=" $flavor"
508514
printf 'Killing %s processes...\n' "$process_name" >&2
509-
pkill -exi -KILL "discord-?$flavor" || printf 'No active processes found.\n' >&2
515+
pkill -exi -KILL "discord${flavor:0:8}" || printf 'No active processes found.\n' >&2
510516
}
511517
512518
bd_injector() {

0 commit comments

Comments
 (0)