home/scripts: refactor
This commit is contained in:
parent
494a7e30ff
commit
fa208b9ac1
2 changed files with 47 additions and 37 deletions
|
@ -67,7 +67,6 @@
|
||||||
modifier = "Mod4";
|
modifier = "Mod4";
|
||||||
keybindings = let
|
keybindings = let
|
||||||
inherit (config.wayland.windowManager.sway.config) modifier;
|
inherit (config.wayland.windowManager.sway.config) modifier;
|
||||||
screenshot = "/home/guanranwang/.local/bin/screenshot";
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
### Sway itself
|
### Sway itself
|
||||||
|
@ -101,9 +100,9 @@
|
||||||
"${modifier}+Shift+Semicolon" = ''exec rofi -modi "power-menu:rofi-power-menu --confirm=reboot/shutdown" -show power-menu'';
|
"${modifier}+Shift+Semicolon" = ''exec rofi -modi "power-menu:rofi-power-menu --confirm=reboot/shutdown" -show power-menu'';
|
||||||
|
|
||||||
# Screenshot
|
# Screenshot
|
||||||
"${modifier}+Shift+s" = "exec ${screenshot} region";
|
"${modifier}+Shift+s" = "exec screenshot region";
|
||||||
"Print" = "exec ${screenshot} fullscreen";
|
"Print" = "exec screenshot fullscreen";
|
||||||
"Print+Control" = "exec ${screenshot} swappy";
|
"Print+Control" = "exec screenshot swappy";
|
||||||
|
|
||||||
# Fn keys
|
# Fn keys
|
||||||
"XF86MonBrightnessUp" = "exec ${lib.getExe pkgs.brightnessctl} set 5%+";
|
"XF86MonBrightnessUp" = "exec ${lib.getExe pkgs.brightnessctl} set 5%+";
|
||||||
|
|
|
@ -1,36 +1,47 @@
|
||||||
{pkgs, ...}: let
|
{pkgs, ...}:
|
||||||
binPATH = ".local/bin";
|
with pkgs; let
|
||||||
|
# trimmed down version of writeShellApplication
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders/default.nix#L245
|
||||||
|
#
|
||||||
|
# it wont work if i change writeTextFile to writeScriptBin... unsure why
|
||||||
|
# error: A definition for option ... is not of type `package'. Definition values:
|
||||||
|
# - In `/nix/store/<hash>-source/nixos/profiles/common/graphical/home/scripts': <function>
|
||||||
|
makeScript = {
|
||||||
|
name,
|
||||||
|
file,
|
||||||
|
runtimeInputs ? [],
|
||||||
|
}:
|
||||||
|
writeTextFile {
|
||||||
|
inherit name;
|
||||||
|
executable = true;
|
||||||
|
destination = "/bin/${name}";
|
||||||
|
text = lib.concatStringsSep "\n" [
|
||||||
|
"#!${runtimeShell}"
|
||||||
|
(lib.optionalString (runtimeInputs != []) ''export PATH="${lib.makeBinPath runtimeInputs}:$PATH"'')
|
||||||
|
(builtins.readFile file)
|
||||||
|
];
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
home.packages = with pkgs; [
|
home.packages = [
|
||||||
#pamixer
|
(makeScript {
|
||||||
#brightnessctl
|
name = "lofi";
|
||||||
grim
|
runtimeInputs = [mpv];
|
||||||
slurp
|
file = pkgs.fetchurl {
|
||||||
swappy
|
url = "https://raw.githubusercontent.com/lime-desu/bin/69422c37582c5914863997c75c268791a0de136e/lofi";
|
||||||
jq
|
hash = "sha256-hT+S/rqOHUYnnFcSDFfQht4l1DGasz1L3wDHKUWLraA=";
|
||||||
#mpvpaper
|
|
||||||
#swww
|
|
||||||
libnotify
|
|
||||||
#dunst
|
|
||||||
];
|
|
||||||
home.sessionPath = ["$HOME/${binPATH}"];
|
|
||||||
home.file = builtins.mapAttrs (_name: value: value // {executable = true;}) {
|
|
||||||
#${binPATH} = {
|
|
||||||
# source = ./bin;
|
|
||||||
# recursive = true;
|
|
||||||
#};
|
|
||||||
|
|
||||||
"${binPATH}/lofi".source = pkgs.fetchurl {
|
|
||||||
url = "https://raw.githubusercontent.com/lime-desu/bin/69422c37582c5914863997c75c268791a0de136e/lofi";
|
|
||||||
hash = "sha256-hT+S/rqOHUYnnFcSDFfQht4l1DGasz1L3wDHKUWLraA=";
|
|
||||||
};
|
|
||||||
|
|
||||||
"${binPATH}/screenshot".source = pkgs.substitute {
|
|
||||||
src = pkgs.fetchurl {
|
|
||||||
url = "https://raw.githubusercontent.com/nwg-piotr/nwg-shell/c29e8eb4658a2613fb221ead0b101c75f457bcaf/scripts/screenshot";
|
|
||||||
hash = "sha256-Z/fWloz8pLHsvPTPOeBxnbMsGDRTY3G3l/uePQ3ZxjU=";
|
|
||||||
};
|
};
|
||||||
replacements = ["--replace" "DIR=\${SCREENSHOT_DIR:=$HOME/Screenshots}" "DIR=$HOME/Pictures/Screenshots"]; # i dont like using an environment variable
|
})
|
||||||
};
|
|
||||||
};
|
(makeScript {
|
||||||
|
name = "screenshot";
|
||||||
|
runtimeInputs = [coreutils jq grim slurp swappy wl-clipboard libnotify];
|
||||||
|
file = pkgs.substitute {
|
||||||
|
src = pkgs.fetchurl {
|
||||||
|
url = "https://raw.githubusercontent.com/nwg-piotr/nwg-shell/c29e8eb4658a2613fb221ead0b101c75f457bcaf/scripts/screenshot";
|
||||||
|
hash = "sha256-Z/fWloz8pLHsvPTPOeBxnbMsGDRTY3G3l/uePQ3ZxjU=";
|
||||||
|
};
|
||||||
|
replacements = ["--replace" "DIR=\${SCREENSHOT_DIR:=$HOME/Screenshots}" "DIR=$HOME/Pictures/Screenshots"]; # i dont like using an environment variable
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue