mirror of
https://github.com/moons-14/dotfiles.git
synced 2026-10-06 05:18:12 +09:00
screenshot
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
{ lib, pkgs, ... }:
|
||||
let
|
||||
screenshot = import ./screenshot.nix { inherit pkgs; };
|
||||
|
||||
systemctl = lib.getExe' pkgs.systemd "systemctl";
|
||||
|
||||
keybind = key: actionAttrs: {
|
||||
@@ -62,8 +60,6 @@ let
|
||||
};
|
||||
in
|
||||
{
|
||||
home.packages = [ screenshot ];
|
||||
|
||||
wayland.windowManager.labwc = {
|
||||
enable = true;
|
||||
# NixOS owns the package so Home Manager only generates the user config.
|
||||
@@ -117,9 +113,9 @@ in
|
||||
(snapToEdge "W-C-Up" "up")
|
||||
(snapToEdge "W-C-Down" "down")
|
||||
(confirmAction "W-S-e" "Exit labwc?" "Exit")
|
||||
(execute "Print" "labwc-screenshot region")
|
||||
(execute "C-Print" "labwc-screenshot output")
|
||||
(execute "A-Print" "labwc-screenshot all")
|
||||
(execute "Print" "screenshot region")
|
||||
(execute "C-Print" "screenshot output")
|
||||
(execute "A-Print" "screenshot all")
|
||||
|
||||
# spawn applications (sync with niri modules/applications/niri/home.nix)
|
||||
(execute "W-t" "ghostty")
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
{
|
||||
description = "labwc Wayland stacking compositor";
|
||||
|
||||
includes = [ "systems.wayland" ];
|
||||
includes = [
|
||||
"systems.wayland"
|
||||
"applications.screenshot"
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "labwc-screenshot";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
coreutils
|
||||
grim
|
||||
slurp
|
||||
wl-clipboard
|
||||
xdg-user-dirs
|
||||
];
|
||||
|
||||
text = ''
|
||||
mode="''${1:-region}"
|
||||
|
||||
pictures_dir="$(xdg-user-dir PICTURES)"
|
||||
if [[ -z "$pictures_dir" ]]; then
|
||||
pictures_dir="$HOME/Pictures"
|
||||
fi
|
||||
|
||||
output_dir="$pictures_dir/Screenshots"
|
||||
output_file="$output_dir/Screenshot from $(date '+%Y-%m-%d %H-%M-%S').png"
|
||||
|
||||
mkdir -p "$output_dir"
|
||||
|
||||
case "$mode" in
|
||||
region)
|
||||
geometry="$(slurp)" || exit 0
|
||||
grim -g "$geometry" "$output_file"
|
||||
;;
|
||||
|
||||
output)
|
||||
geometry="$(slurp -o)" || exit 0
|
||||
grim -g "$geometry" "$output_file"
|
||||
;;
|
||||
|
||||
all)
|
||||
grim "$output_file"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown screenshot mode: $mode" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
wl-copy --type image/png < "$output_file"
|
||||
'';
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
# niri のデフォルトキーバインド。編集しないこと。
|
||||
{
|
||||
"Mod+Shift+Slash".action.show-hotkey-overlay = { };
|
||||
|
||||
|
||||
@@ -41,6 +41,19 @@ in
|
||||
hotkey-overlay.title = "Move Window to Monitor Down";
|
||||
};
|
||||
|
||||
"Print".action.spawn = [
|
||||
"screenshot"
|
||||
"region"
|
||||
];
|
||||
"Ctrl+Print".action.spawn = [
|
||||
"screenshot"
|
||||
"output"
|
||||
];
|
||||
"Alt+Print".action.spawn = [
|
||||
"screenshot"
|
||||
"all"
|
||||
];
|
||||
|
||||
# spawn applications (sync with labwc modules/applications/labwc/home.nix)
|
||||
"Mod+T" = {
|
||||
action.spawn = "ghostty";
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
{
|
||||
description = "niri Wayland compositor";
|
||||
|
||||
includes = [ "systems.wayland" ];
|
||||
includes = [
|
||||
"systems.wayland"
|
||||
"applications.screenshot"
|
||||
];
|
||||
|
||||
imports = {
|
||||
nixos = [
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = [
|
||||
(pkgs.writeShellApplication {
|
||||
name = "screenshot";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
coreutils
|
||||
grim
|
||||
slurp
|
||||
wl-clipboard
|
||||
xdg-user-dirs
|
||||
];
|
||||
|
||||
text = ''
|
||||
mode="''${1:-region}"
|
||||
|
||||
pictures_dir="$(xdg-user-dir PICTURES)"
|
||||
if [[ -z "$pictures_dir" ]]; then
|
||||
pictures_dir="$HOME/Pictures"
|
||||
fi
|
||||
|
||||
output_dir="$pictures_dir/Screenshots"
|
||||
output_file="$output_dir/Screenshot from $(date '+%Y-%m-%d %H-%M-%S').png"
|
||||
|
||||
mkdir -p "$output_dir"
|
||||
|
||||
case "$mode" in
|
||||
region)
|
||||
geometry="$(slurp)" || exit 0
|
||||
grim -g "$geometry" "$output_file"
|
||||
;;
|
||||
|
||||
output)
|
||||
geometry="$(slurp -o)" || exit 0
|
||||
grim -g "$geometry" "$output_file"
|
||||
;;
|
||||
|
||||
all)
|
||||
grim "$output_file"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown screenshot mode: $mode" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
wl-copy --type image/png < "$output_file"
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
description = "Wayland screenshot command";
|
||||
}
|
||||
@@ -2,8 +2,6 @@
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
alacritty
|
||||
grim
|
||||
slurp
|
||||
wf-recorder
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
alacritty
|
||||
grim
|
||||
slurp
|
||||
wf-recorder
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user