❄ Personal NixOS Flake Manager
nixos home-manager go nix
0
fork

Configure Feed

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

feat(rui): custom notifier support

Fuwn d19e14a3 77b565b7

+43 -5
+31
README.md
··· 51 51 # Status notifications via `notify-send` 52 52 notify = true; 53 53 54 + # The command to use for sending notifications, view a cool example below! 55 + notifier = "notify-send"; 56 + 54 57 # Rui falls back on the `FLAKE_EDITOR` and `EDITOR` environment variables 55 58 editor = "code"; 56 59 ··· 79 82 hash = "..."; # Use the current commit sha256 hash 80 83 } 81 84 )).packages.${builtins.currentSystem}.default 85 + ``` 86 + 87 + ## Custom Notification Command Example 88 + 89 + Rui uses `notify-send` by default for sending notifications, but you can set 90 + the `notifier` configuration value to any file path. Here's an example of a 91 + distributed notification script that sends notifications to your phone **and** 92 + your PC. This can easily be adapted to send notifications to any service, e.g., 93 + Telegram, Discord, other webhook receivers, etc. 94 + 95 + This example uses [Bark](https://bark.day.app/#/?id=%E6%BA%90%E7%A0%81), an 96 + extremely simple and easy-to-use notification service for iOS devices. 97 + 98 + ```sh 99 + #!/usr/bin/env dash 100 + 101 + # Send a notification to your host PC 102 + notify-send "$1" "$2" 103 + 104 + # Send a notification to your iOS device 105 + curl -X "POST" "https://api.day.app/your_bark_api_key" \ 106 + -H 'Content-Type: application/json; charset=utf-8' \ 107 + --silent \ 108 + -d '{ 109 + "body": "'"${2}"'", 110 + "title": "'"${1}"'", 111 + "icon": "https://nixos.wiki/images/thumb/2/20/Home-nixos-logo.png/207px-Home-nixos-logo.png" 112 + }' 82 113 ``` 83 114 84 115 ## `--help`
+1 -1
flake.nix
··· 41 41 { 42 42 packages.default = pkgs.buildGoModule { 43 43 pname = "rui"; 44 - version = "2024.09.22"; 44 + version = "2024.09.23"; 45 45 src = pkgs.lib.cleanSource ./.; 46 46 vendorHash = "sha256-mN/QjzJ4eGfbW1H92cCKvC0wDhCR6IUes2HCZ5YBdPA="; 47 47
+11 -4
rui.go
··· 11 11 ) 12 12 13 13 type Configuration struct { 14 - Notify bool `json:"notify"` 15 - Editor string `json:"editor"` 16 - Flake string `json:"flake"` 14 + Notify bool `json:"notify"` 15 + Editor string `json:"editor"` 16 + Flake string `json:"flake"` 17 + Notifier string `json:"notifier"` 17 18 } 18 19 19 20 type ActionDetails struct { ··· 215 216 return nil 216 217 } 217 218 218 - notifySend, err := exec.LookPath("notify-send") 219 + notifier := configuration.Notifier 220 + 221 + if notifier == "" { 222 + notifier = "notify-send" 223 + } 224 + 225 + notifySend, err := exec.LookPath(notifier) 219 226 220 227 if err != nil { 221 228 return nil