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/conf/xmonad.hs | 1 - gui/default.nix | 2 ++ gui/pkgs/tasker.nix | 47 +++++++++++++++++++++++++++++------------------ gui/tasker.nix | 20 ++++++++++++++++++++ gui/xmonad.nix | 6 +----- 5 files changed, 52 insertions(+), 24 deletions(-) create mode 100644 gui/tasker.nix (limited to 'gui') diff --git a/gui/conf/xmonad.hs b/gui/conf/xmonad.hs index f1222a7..668d818 100644 --- a/gui/conf/xmonad.hs +++ b/gui/conf/xmonad.hs @@ -145,7 +145,6 @@ commonKeybindings host = , ("C-M1-l" , spawn "i3lock -c 000000") -- application launchers , ("M-" , spawn "rofi -show combi") - , ("C-" , spawn "tasker") , ("M-" , spawn "kitty") , ("M-S-" , spawn "nvim-qt --no-ext-tabline") , ("" , spawn "flameshot gui") diff --git a/gui/default.nix b/gui/default.nix index 2cc011e..6948139 100644 --- a/gui/default.nix +++ b/gui/default.nix @@ -9,6 +9,8 @@ in { ./kitty.nix ./vim.nix ./zathura.nix + # desktop shortcuts for project specific tasks + ./tasker.nix # applications grouped by purpose ./apps/file.nix ./apps/web.nix 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 diff --git a/gui/tasker.nix b/gui/tasker.nix new file mode 100644 index 0000000..bb006fa --- /dev/null +++ b/gui/tasker.nix @@ -0,0 +1,20 @@ +{ pkgs, ... }: + +let + tasks = { + "bsc_edit" = { + description = "Grid refinement BSc thesis editor"; + directory = "~/university/documents/bachelor/arbeit"; + command = "nix-shell --run 'nvim-qt --no-ext-tabline'"; + }; + "bsc_view" = { + description = "Grid refinement BSc thesis PDF"; + directory = "~/university/documents/bachelor/arbeit"; + command = "evince build/main.pdf"; + }; + }; +in { + home.packages = let + task_derivations = pkgs.callPackage ./pkgs/tasker.nix { inherit pkgs; inherit tasks; }; + in task_derivations; +} diff --git a/gui/xmonad.nix b/gui/xmonad.nix index f265278..52de48d 100644 --- a/gui/xmonad.nix +++ b/gui/xmonad.nix @@ -26,13 +26,9 @@ in { }; }; - home.packages = let - tasker = pkgs.lib.callPackageWith pkgs ./pkgs/tasker.nix { }; - in with pkgs; [ + home.packages = with pkgs; [ # lockscreen i3lock - # task launcher - tasker ]; services.screen-locker = { -- cgit v1.2.3