From 269b48b6d6e9fcae3ca87c6324b820a5024de837 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Mon, 12 Oct 2020 23:05:15 +0200 Subject: [PATCH] browser: add kill commands --- modules/programs/browser.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/programs/browser.nix b/modules/programs/browser.nix index 910d7a5..d9c6fd7 100644 --- a/modules/programs/browser.nix +++ b/modules/programs/browser.nix @@ -37,6 +37,9 @@ let ''; }; + killBrowser = name: + pkgs.writeShellScriptBin "${name}-kill" "sudo killall -9 -u ${name}"; + cleanBrowser = name: browser: home: homeBackup: let backupFile = "${homeBackup}.tar.lzma"; @@ -45,7 +48,7 @@ let in pkgs.writeShellScriptBin "${name}-clean" # sh '' sudo killall -9 -u ${name} - sudo rm ${lockFile} + sudo rm -f ${lockFile} sudo rm -rf ${home} ''; @@ -129,6 +132,8 @@ let cleanBrowser name name browserConfig.home browserConfig.homeBackup) filteredConfigs; + allKillScripts = mapAttrsToList (name: _: killBrowser name) cfg.configList; + # browser chooser # --------------- browserSelect = pkgs.writeScriptBin "browser-select" '' @@ -210,7 +215,7 @@ in { ${sudoUser} ALL=(root) NOPASSWD: /run/current-system/sw/bin/chown -R ${values.user}\:users ${values.home} ${sudoUser} ALL=(root) NOPASSWD: /run/current-system/sw/bin/killall -9 -u ${name} ${sudoUser} ALL=(root) NOPASSWD: /run/current-system/sw/bin/rm -rf ${values.home} - ${sudoUser} ALL=(root) NOPASSWD: /run/current-system/sw/bin/rm ${values.home}-lock + ${sudoUser} ALL=(root) NOPASSWD: /run/current-system/sw/bin/rm -f ${values.home}-lock '') values.sudoUsers)); in lib.concatStringsSep "\n" extraRules; @@ -232,7 +237,7 @@ in { environment.systemPackages = [ browserSelect (desktopFile browserSelect) ] ++ browserExecutableList ++ (map (bin: desktopFile bin) browserExecutableList) ++ allBackupScripts - ++ allCleanScripts; + ++ allCleanScripts ++ allKillScripts; }; }