-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
174a41d
commit a42bf15
Showing
2 changed files
with
26 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,17 @@ | ||
{ | ||
hostname, | ||
lib, | ||
pkgs, | ||
... | ||
}: | ||
{ pkgs, ... }: | ||
let | ||
installOn = [ | ||
"phasma" | ||
"vader" | ||
]; | ||
name = builtins.baseNameOf (builtins.toString ./.); | ||
shellApplication = pkgs.writeShellApplication { | ||
inherit name; | ||
runtimeInputs = with pkgs; [ | ||
coreutils-full | ||
gnugrep | ||
usb-reset | ||
usbutils | ||
]; | ||
text = builtins.readFile ./${name}.sh; | ||
}; | ||
in | ||
lib.mkIf (lib.elem hostname installOn) { home.packages = with pkgs; [ shellApplication ]; } | ||
{ | ||
home.packages = with pkgs; [ shellApplication ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
VENDOR="31e9" | ||
PRODUCT="0001" | ||
HOST=$(hostnamectl hostname) | ||
case "${HOST}" in | ||
phasma) usb-reset 31e9:0002;; | ||
vader) usb-reset 31e9:0001;; | ||
phasma) PRODUCT="0002";; | ||
*) echo "This script is only meant to be run on phasma or vader";; | ||
esac | ||
|
||
sudo true | ||
# If usb-reset is installed, use it | ||
if [ -x "$(command -v usb-reset)" ]; then | ||
sudo usb-reset ${VENDOR}:${PRODUCT} | ||
elif [ -x "$(command -v usbreset)" ]; then | ||
# Get the bus and device number of the SSL 2 | ||
SSL2="$(lsusb -d ${VENDOR}: | grep "SSL 2")" | ||
#Bus 001 Device 007: ID 31e9:0001 Solid State Logic SSL 2 | ||
#Bus 001 Device 009: ID 31e9:0002 Solid State Logic SSL 2+ | ||
BUS="$(echo "${SSL2}" | cut -d' ' -f 2)" | ||
DEV="$(echo "${SSL2}" | cut -d' ' -f 4 | cut -d':' -f 1)" | ||
sudo usbreset ${BUS}/${DEV} | ||
else | ||
echo "ERROR! usb-reset or usbreset is not installed. Please install it." | ||
exit 1 | ||
fi |