aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-02-22 12:30:35 +0100
committerAdrian Kummerlaender2019-02-22 12:30:35 +0100
commita0c8daf64aaa392949b99d5e5ae5df9a763dfec8 (patch)
tree362a32a4c46ebc5c45e03d65c2efc96a3ea46b7a
parentcfab1689f5723129f0bfbb79eaabecf8e809905b (diff)
downloadnixos_home-a0c8daf64aaa392949b99d5e5ae5df9a763dfec8.tar
nixos_home-a0c8daf64aaa392949b99d5e5ae5df9a763dfec8.tar.gz
nixos_home-a0c8daf64aaa392949b99d5e5ae5df9a763dfec8.tar.bz2
nixos_home-a0c8daf64aaa392949b99d5e5ae5df9a763dfec8.tar.lz
nixos_home-a0c8daf64aaa392949b99d5e5ae5df9a763dfec8.tar.xz
nixos_home-a0c8daf64aaa392949b99d5e5ae5df9a763dfec8.tar.zst
nixos_home-a0c8daf64aaa392949b99d5e5ae5df9a763dfec8.zip
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.
-rw-r--r--gui/conf/xmonad.hs1
-rw-r--r--gui/default.nix2
-rw-r--r--gui/pkgs/tasker.nix47
-rw-r--r--gui/tasker.nix20
-rw-r--r--gui/xmonad.nix6
5 files changed, 52 insertions, 24 deletions
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-<Space>" , spawn "rofi -show combi")
- , ("C-<Space>" , spawn "tasker")
, ("M-<Return>" , spawn "kitty")
, ("M-S-<Return>" , spawn "nvim-qt --no-ext-tabline")
, ("<Print>" , 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 = {