From a0c8daf64aaa392949b99d5e5ae5df9a763dfec8 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 22 Feb 2019 12:30:35 +0100 Subject: Nixify project task launcher Task scripts and desktop shortcuts are now autogenerated using a friendly list of tasks in `gui/tasker.nix`. i.e. a separate rofi launcher is unnecessary as the generated desktop files are automatically picked up by stock rofi. This is nice. --- gui/pkgs/tasker.nix | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'gui/pkgs') diff --git a/gui/pkgs/tasker.nix b/gui/pkgs/tasker.nix index a198cb8..2382be2 100644 --- a/gui/pkgs/tasker.nix +++ b/gui/pkgs/tasker.nix @@ -1,19 +1,30 @@ -{ stdenv, pkgs, ... }: +{ pkgs, tasks, ... }: -pkgs.writeTextFile { - name = "tasker"; - executable = true; - destination = "/bin/tasker"; - - text = with pkgs; '' - #!${fish}/bin/fish - - pushd ~/.local/share/tasks - set task (find . -executable -type f | cut -c3- | rofi -dmenu -p "task") - - if test $status -eq 0 - eval $task - end - popd - ''; -} +pkgs.lib.mapAttrsToList (name: value: let + command = pkgs.writeTextFile { + name = "tasker_cmd_" + name; + executable = true; + destination = "/bin/tasker_cmd_" + name; + text = '' + #!/bin/sh + pushd ${toString value.directory} + exec ${toString value.command} + popd + ''; + }; + shortcut = pkgs.writeTextFile { + name = "tasker_shortcut_" + name; + executable = false; + destination = "/share/applications/tasker_shortcut_" + name + ".desktop"; + text = '' + [Desktop Entry] + Type=Application + Name=${toString value.description} + Exec=${command}/bin/tasker_cmd_${toString name} + Terminal=false + ''; + }; +in pkgs.symlinkJoin { + name = "tasker_task_" + name; + paths = [ shortcut ]; +}) tasks -- cgit v1.2.3