diff options
author | Profpatsch <mail@profpatsch.de> | 2018-03-28 07:33:39 +0200 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2018-05-01 21:28:02 +0200 |
commit | 2a22d5c54f923ece8247dd4095afeea3ed7cf7d4 (patch) | |
tree | 210c256917afd62664975843f9d3f5a279ce089f /machines | |
parent | 815211add6078eb2f223e07a4efbd89880ddcb9e (diff) |
machines/katara: add user services for pyrnotify
Diffstat (limited to 'machines')
-rw-r--r-- | machines/profpatsch/katara.nix | 30 | ||||
-rw-r--r-- | machines/profpatsch/patches/libnotify.patch | 39 | ||||
-rw-r--r-- | machines/profpatsch/pkgs.nix | 20 |
3 files changed, 88 insertions, 1 deletions
diff --git a/machines/profpatsch/katara.nix b/machines/profpatsch/katara.nix index 2e480da9..68e91981 100644 --- a/machines/profpatsch/katara.nix +++ b/machines/profpatsch/katara.nix @@ -400,6 +400,36 @@ in { }; } + ({ + services.pyrnotify-ssh-connection = { + description = "ssh connection to make pyrnotify work"; + serviceConfig = { + Environment = ''"SSH_AUTH_SOCK=%t/gnupg/S.gpg-agent.ssh"''; + # forwards the remote socket over ssh, restarts every 5 minutes + ExecStart = pkgs.writeScript "pyrnotify-start-ssh" '' + #!${pkgs.stdenv.shell} + ${lib.getBin pkgs.openssh}/bin/ssh \ + bigmac \ + "rm /home/bigmac/.weechat/pyrnotify.socket" + ${lib.getBin pkgs.openssh}/bin/ssh \ + -R /home/bigmac/.weechat/pyrnotify.socket:localhost:8099 \ + bigmac \ + "sleep 300" + ''; + Restart = "on-failure"; + }; + }; + services.pyrnotify-listen = rec { + description = "get notified about weechat messages"; + serviceConfig = { + ExecStart = "${lib.getBin pkgs.python + }/bin/python ${myPkgs.pyrnotify} 8099"; + }; + requires = [ "pyrnotify-ssh-connection.service" ]; + after = requires; + }; + }) + ]; }; diff --git a/machines/profpatsch/patches/libnotify.patch b/machines/profpatsch/patches/libnotify.patch new file mode 100644 index 00000000..88bb545e --- /dev/null +++ b/machines/profpatsch/patches/libnotify.patch @@ -0,0 +1,39 @@ +From 15f0781e728700d8c752a4f0d2e8aaffd8c5ae7c Mon Sep 17 00:00:00 2001 +From: Profpatsch <mail@profpatsch.de> +Date: Wed, 28 Mar 2018 06:35:27 +0200 +Subject: [PATCH] tools/notify-send.c: return error if message show fails +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +If for example the dbus session can’t be reached, `notify_notification_show` +will fail and return an error. +--- + tools/notify-send.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/tools/notify-send.c b/tools/notify-send.c +index abfffe6..04fad7f 100644 +--- a/tools/notify-send.c ++++ b/tools/notify-send.c +@@ -274,8 +274,15 @@ main (int argc, char *argv[]) + } + } + +- if (!hint_error) +- notify_notification_show (notify, NULL); ++ if (!hint_error) { ++ retval = notify_notification_show (notify, &error); ++ if (!retval) { ++ fprintf (stderr, "notify-send: error showing notification libnotify says: %s\n", ++ error->message); ++ g_error_free (error); ++ exit (1); ++ } ++ } + + g_object_unref (G_OBJECT (notify)); + +-- +2.16.2 + diff --git a/machines/profpatsch/pkgs.nix b/machines/profpatsch/pkgs.nix index 9cff23fa..7fd1db01 100644 --- a/machines/profpatsch/pkgs.nix +++ b/machines/profpatsch/pkgs.nix @@ -88,6 +88,22 @@ let # buildDepends = with haskellPackages; [ hnix ansi-wl-pprint protolude data-fix ]; # }; + pyrnotify = + let src = pkgs.fetchFromGitHub { + owner = "arnottcr"; + repo = "weechat-pyrnotify"; + rev = "5063ba19b5ba7ba3d4ecb2a76ad9e4b7bf89964b"; + sha256 = "0r07glz7hkmcnp2vl4dy24i9vfsa9shm7k4q0jb47881z0y2dm2p"; + }; + notify-send = "${pkgs.libnotify.overrideAttrs (old: { + patches = old.patches or [] ++ [ ./patches/libnotify.patch ]; + })}/bin/notify-send"; + in pkgs.runCommand "pyrnotify.py" {} '' + substitute "${src}/pyrnotify.py" $out \ + --replace 'notify-send' '${notify-send}' + ''; + + in { inherit taffybar @@ -99,5 +115,7 @@ in xmpp-client saneGhci /*nix-gen*/ - /*searx*/; + /*searx*/ + pyrnotify + ; } |