This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools.pi: play peon sounds on permission prompts via pw-play

+41
+7
tools/pi/flake-module.nix
··· 32 32 # - Remove the resistance extension (annoying terminator quote widget) 33 33 # - Rebind ultrathink ctrl+u -> ctrl+shift+u (conflicts with deleteToLineStart) 34 34 # - Rebind speedreading ctrl+r -> ctrl+shift+r (conflicts with renameSession) 35 + # Patch pi-hooks: 36 + # - Replace terminal bell with pw-play peon sounds in permission extension 35 37 pluginPrefix = pkgs.runCommand "pi-plugins" { } '' 36 38 cp -a ${pluginPrefixRaw} $out 37 39 chmod -R u+w $out ··· 42 44 # Fix keybinding conflicts in extension source 43 45 ${pkgs.gnused}/bin/sed -i 's/"ctrl+u"/"ctrl+shift+u"/' $out/lib/node_modules/shitty-extensions/extensions/ultrathink.ts 44 46 ${pkgs.gnused}/bin/sed -i 's/"ctrl+r"/"ctrl+shift+r"/' $out/lib/node_modules/shitty-extensions/extensions/speedreading.ts 47 + 48 + # Patch permission extension to use pw-play for peon sounds on Linux 49 + ${pkgs.python3}/bin/python3 ${./patch-permission-sound.py} \ 50 + $out/lib/node_modules/pi-hooks/permission/permission.ts \ 51 + ${pkgs.pipewire}/bin/pw-play 45 52 ''; 46 53 in 47 54 {
+34
tools/pi/patch-permission-sound.py
··· 1 + #!/usr/bin/env python3 2 + """Patch pi-hooks permission extension to play peon sounds via pw-play on Linux.""" 3 + import re 4 + import sys 5 + 6 + ts_file = sys.argv[1] 7 + pw_play = sys.argv[2] 8 + 9 + src = open(ts_file).read() 10 + 11 + replacement = """function playPermissionSound(): void { 12 + const isMac = process.platform === "darwin"; 13 + if (isMac) { 14 + exec('afplay /System/Library/Sounds/Funk.aiff 2>/dev/null', (err) => { 15 + if (err) process.stdout.write("\\x07"); 16 + }); 17 + } else { 18 + const n = Math.floor(Math.random() * 4) + 1; 19 + exec(`""" + pw_play + """ "$HOME/src/sounds/games/Warcraft III/Units/Orc/Peon/PeonWhat${n}.wav"`, () => {}); 20 + } 21 + }""" 22 + 23 + result = re.sub( 24 + r'function playPermissionSound\(\): void \{.*?\n\}', 25 + replacement, 26 + src, 27 + flags=re.DOTALL, 28 + ) 29 + 30 + if result == src: 31 + print("ERROR: playPermissionSound function not found in", ts_file, file=sys.stderr) 32 + sys.exit(1) 33 + 34 + open(ts_file, 'w').write(result)