1
0
Fork 0

pallas: manage EventScripts scripts

This commit is contained in:
Daniel Kempkens 2024-11-16 18:56:39 +01:00
parent 160073943a
commit e8db349c81
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM
2 changed files with 43 additions and 0 deletions

View file

@ -26,6 +26,8 @@ in
../programs/btop.nix ../programs/btop.nix
../programs/event-scripts.nix
../programs/gallery-dl.nix ../programs/gallery-dl.nix
../programs/gpg.nix ../programs/gpg.nix

View file

@ -0,0 +1,41 @@
{ pkgs, ... }:
{
home.file =
let
scriptDirectory = "Library/Application Scripts/net.mousedown.EventScripts";
fullScriptDirectoryPath = "$HOME/${scriptDirectory}";
mosquitto_pub = "${pkgs.mosquitto}/bin/mosquitto_pub";
in
{
"${scriptDirectory}/.hm_keyboard_connected.sh" = {
text = ''
#!/bin/sh
if [ "$2" = "Keychron Q1" ]; then
${mosquitto_pub} -h 10.0.0.230 -m "USB-C" -t hadata/macos/daniels_monitor -u mqtt_bridge -P verySecurePassword
fi
'';
onChange = ''
rm -f "${fullScriptDirectoryPath}/keyboard_connected.sh"
cp "${fullScriptDirectoryPath}/.hm_keyboard_connected.sh" "${fullScriptDirectoryPath}/keyboard_connected.sh"
'';
executable = true;
};
"${scriptDirectory}/.hm_keyboard_disconnected.sh" = {
text = ''
#!/bin/sh
if [ "$2" = "Keychron Q1" ]; then
${mosquitto_pub} -h 10.0.0.230 -m "DisplayPort" -t hadata/macos/daniels_monitor -u mqtt_bridge -P verySecurePassword
fi
'';
onChange = ''
rm -f "${fullScriptDirectoryPath}/keyboard_disconnected.sh"
cp "${fullScriptDirectoryPath}/.hm_keyboard_disconnected.sh" "${fullScriptDirectoryPath}/keyboard_disconnected.sh"
'';
executable = true;
};
};
}