mirror of
https://github.com/ItsDrike/nixdots
synced 2025-05-12 23:08:37 +00:00
Compare commits
No commits in common. "8808ac6be4b73e0c491f9eb7614bbd2a491f04f9" and "874cbcec703a08d13b507bab4ca5d8d3c8242eb2" have entirely different histories.
8808ac6be4
...
874cbcec70
11 changed files with 4 additions and 313 deletions
|
@ -8,35 +8,7 @@
|
||||||
in {
|
in {
|
||||||
config = mkIf osConfig.myOptions.home-manager.wms.isWayland {
|
config = mkIf osConfig.myOptions.home-manager.wms.isWayland {
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
wl-clipboard # clipboard interactions
|
wl-clipboard
|
||||||
grim # grab images
|
|
||||||
slurp # select a region
|
|
||||||
wf-recorder # screen recording
|
|
||||||
|
|
||||||
# Grabs text from screenshot image
|
|
||||||
(pkgs.writeShellApplication {
|
|
||||||
name = "ocr";
|
|
||||||
runtimeInputs = with pkgs; [tesseract grim slurp coreutils];
|
|
||||||
text = ''
|
|
||||||
echo "Generating a random ID..."
|
|
||||||
id=$(tr -dc 'a-zA-Z0-9' </dev/urandom | fold -w 6 | head -n 1 || true)
|
|
||||||
echo "Image ID: $id"
|
|
||||||
|
|
||||||
echo "Taking screenshot..."
|
|
||||||
grim -g "$(slurp -w 0)" /tmp/ocr-"$id".png
|
|
||||||
|
|
||||||
echo "Running OCR..."
|
|
||||||
tesseract /tmp/ocr-"$id".png - | wl-copy
|
|
||||||
echo -en "File saved to /tmp/ocr-'$id'.png\n"
|
|
||||||
|
|
||||||
|
|
||||||
echo "Sending notification..."
|
|
||||||
notify-send "OCR " "Text copied!"
|
|
||||||
|
|
||||||
echo "Cleaning up..."
|
|
||||||
rm /tmp/ocr-"$id".png -vf
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,5 @@ _: {
|
||||||
./wayland.nix
|
./wayland.nix
|
||||||
./stremio.nix
|
./stremio.nix
|
||||||
./nomacs.nix
|
./nomacs.nix
|
||||||
./qbittorrent.nix
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
osConfig,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (lib) mkIf;
|
|
||||||
|
|
||||||
cfg = osConfig.myOptions.home-manager.programs.applications.qbittorrent;
|
|
||||||
in {
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
home.packages = with pkgs; [
|
|
||||||
qbittorrent
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
in {
|
in {
|
||||||
config = mkIf osConfig.myOptions.home-manager.wms.isWayland {
|
config = mkIf osConfig.myOptions.home-manager.wms.isWayland {
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
wlogout # logout menu
|
wlogout
|
||||||
swappy # screenshot editing
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, ... }: {
|
{
|
||||||
wayland.windowManager.hyprland = {
|
wayland.windowManager.hyprland = {
|
||||||
settings = {
|
settings = {
|
||||||
"$MOUSE_LMB" = "mouse:272";
|
"$MOUSE_LMB" = "mouse:272";
|
||||||
|
@ -9,9 +9,6 @@
|
||||||
|
|
||||||
"$XF86Favorites" = "164";
|
"$XF86Favorites" = "164";
|
||||||
|
|
||||||
"$SCREENSHOT_FORMAT" = "${config.xdg.userDirs.extraConfig.XDG_SCREENSHOTS_DIR}/Screenshot_''$(date +%Y-%m-%d_%H-%M-%S).png";
|
|
||||||
"$SCREENSHOT_DELAY" = "2000";
|
|
||||||
|
|
||||||
bind = [
|
bind = [
|
||||||
#
|
#
|
||||||
# Active window
|
# Active window
|
||||||
|
@ -39,21 +36,7 @@
|
||||||
#
|
#
|
||||||
# Screenshots
|
# Screenshots
|
||||||
#
|
#
|
||||||
"ALT, Print, exec, wl-copy \"$(hyprpicker)\" && notify-send 'Picked color' \"$(wl-paste) (saved to clipboard)\""
|
# TODO: requires script
|
||||||
", Print, exec, hyprland-screenshot --notify --copy --target area"
|
|
||||||
"SUPER, Print, exec, hyprland-screenshot --notify --copy --target area --edit"
|
|
||||||
"SHIFT, Print, exec, hyprland-screenshot --notify --save $SCREENSHOT_FORMAT --target area"
|
|
||||||
"CTRL, Print, exec, hyprland-screenshot --notify --copy --target area --delay $SCREENSHOT_DELAY"
|
|
||||||
"SUPER_SHIFT, Print, exec, hyprland-screenshot --notify --save $SCREENSHOT_FORMAT --target area --edit"
|
|
||||||
"SUPER_CTRL, Print, exec, hyprland-screenshot --notify --copy --target area --delay $SCREENSHOT_DELAY --edit"
|
|
||||||
"SUPER_SHIFT_CTRL, Print, exec, hyprland-screenshot --notify --save $SCREENSHOT_FORMAT --target area --delay $SCREENSHOT_DELAY --edit"
|
|
||||||
"CTRL, T, exec, hyprland-screenshot --save $SCREENSHOT_FORMAT --target all"
|
|
||||||
#" , Print, exec, screenshot --save $SCREENSHOT_FORMAT --target all"
|
|
||||||
|
|
||||||
# XF86Favorites key for recording
|
|
||||||
# (don't question me, I had it free)
|
|
||||||
", $XF86Favorites, exec, quick-record --notify toggle"
|
|
||||||
"SUPER, $XF86Favorites, exec, quick-record toggle"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Brightness control
|
# Brightness control
|
||||||
|
|
|
@ -17,9 +17,7 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home.packages = [
|
home.packages = [
|
||||||
hyprPkgs.hyprland-move-window
|
hyprPkgs.hyprland-move-window
|
||||||
hyprPkgs.hyprland-screenshot
|
|
||||||
pkgs.brightnessctl
|
pkgs.brightnessctl
|
||||||
pkgs.hyprpicker
|
|
||||||
hyprPkgs.brightness
|
hyprPkgs.brightness
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
packages = {
|
packages = {
|
||||||
hyprland-move-window = pkgs.callPackage ./hyprland-move-window {};
|
hyprland-move-window = pkgs.callPackage ./hyprland-move-window {};
|
||||||
brightness = pkgs.callPackage ./brightness {};
|
brightness = pkgs.callPackage ./brightness {};
|
||||||
hyprland-screenshot = pkgs.callPackage ./hyprland-screenshot {};
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
packages
|
packages
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
# - `grim`: screenshot utility for wayland
|
|
||||||
# - `slurp`: to select an area
|
|
||||||
# - `hyprctl`: to read properties of current window
|
|
||||||
# - `wl-copy`: clipboard utility
|
|
||||||
# - `jq`: json utility to parse hyprctl output
|
|
||||||
# - `notify-send`: to show notifications
|
|
||||||
# - `swappy`: for editing the screenshots (only required for --edit)
|
|
||||||
|
|
||||||
{pkgs, ...}:
|
|
||||||
pkgs.writeShellApplication {
|
|
||||||
name = "hyprland-screenshot";
|
|
||||||
runtimeInputs = with pkgs; [
|
|
||||||
jq
|
|
||||||
grim
|
|
||||||
slurp
|
|
||||||
swappy
|
|
||||||
wl-clipboard
|
|
||||||
libnotify
|
|
||||||
hyprland
|
|
||||||
];
|
|
||||||
text = ''
|
|
||||||
${builtins.readFile ./hyprland-screenshot.sh}
|
|
||||||
'';
|
|
||||||
}
|
|
|
@ -1,216 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Inspired by grimblast (https://github.com/hyprwm/contrib/blob/main/grimblast/grimblast)
|
|
||||||
|
|
||||||
# Helper functions
|
|
||||||
|
|
||||||
die() {
|
|
||||||
MSG="${1}"
|
|
||||||
ERR_CODE="${2:-1}"
|
|
||||||
URGENCY="${3:-critical}"
|
|
||||||
|
|
||||||
>&2 echo "$MSG"
|
|
||||||
if [ "$NOTIFY" = "yes" ]; then
|
|
||||||
notify-send -a screenshot -u "$URGENCY" "Error ($ERR_CODE)" "$MSG"
|
|
||||||
fi
|
|
||||||
exit "$ERR_CODE"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Argument parsing
|
|
||||||
|
|
||||||
SAVE_METHOD=
|
|
||||||
SAVE_FILE=
|
|
||||||
TARGET=
|
|
||||||
NOTIFY=no
|
|
||||||
CURSOR=no
|
|
||||||
EDIT=no
|
|
||||||
DELAY=0
|
|
||||||
|
|
||||||
while [ "${1-}" ]; do
|
|
||||||
case "$1" in
|
|
||||||
-h | --help)
|
|
||||||
>&2 cat <<EOF
|
|
||||||
screenshot taking utility script, allowing for easy all-in-one solution for
|
|
||||||
controlling how a screenshot should be taken.
|
|
||||||
|
|
||||||
Methods (one is required):
|
|
||||||
--copy: Copy the screenshot data into the clipboard
|
|
||||||
--save [FILE]: Save the screenshot data into a file
|
|
||||||
--copysave [FILE]: Both save to clipboard and to file
|
|
||||||
General options:
|
|
||||||
--notify: Send a notification that the screenshot was saved
|
|
||||||
--cursor: Capture cursor in the screenshot
|
|
||||||
--edit: Once the screenshot is taken, edit it first with swappy
|
|
||||||
--delay [MILISECONDS]: Wait for given time until the screenshot is taken
|
|
||||||
--target [TARGET]: (REQUIRED) What should be captured
|
|
||||||
Variables:
|
|
||||||
FILE: A path to a .png image file for output, or '-' to pipe to STDOUT
|
|
||||||
MILISECONDS: Number of miliseconds; Must be a whole, non-negative number!
|
|
||||||
TARGET: Area on screen; can be one of:
|
|
||||||
- activewin: Currently active window
|
|
||||||
- window: Manually select a window
|
|
||||||
- activemon: Currently active monitor (output)
|
|
||||||
- monitor: Manually select a monitor
|
|
||||||
- all: Everything (all visible monitors/outputs)
|
|
||||||
- area: Manually select a region
|
|
||||||
EOF
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
--notify)
|
|
||||||
NOTIFY=yes
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--cursor)
|
|
||||||
CURSOR=yes
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--edit)
|
|
||||||
EDIT=yes
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--target)
|
|
||||||
if [ -z "$TARGET" ]; then
|
|
||||||
case "$2" in
|
|
||||||
activewin | window | activemon | monitor | all | area)
|
|
||||||
TARGET="$2"
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
die "Invalid target (see TARGET variable in --help)"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
die "Only one target can be passed."
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
--delay)
|
|
||||||
case "$2" in
|
|
||||||
'' | *[!0-9]*)
|
|
||||||
die "Argument after --delay must be an amount of MILISECONDS"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
DELAY="$2"
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
|
|
||||||
--copy)
|
|
||||||
if [ -z "$SAVE_METHOD" ]; then
|
|
||||||
SAVE_METHOD="copy"
|
|
||||||
shift
|
|
||||||
else
|
|
||||||
die "Only one method can be passed."
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
--save)
|
|
||||||
if [ -z "$SAVE_METHOD" ]; then
|
|
||||||
SAVE_METHOD="save"
|
|
||||||
SAVE_FILE="$2"
|
|
||||||
shift 2
|
|
||||||
else
|
|
||||||
die "Only one method can be passed."
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
--copysave)
|
|
||||||
if [ -z "$SAVE_METHOD" ]; then
|
|
||||||
SAVE_METHOD="copysave"
|
|
||||||
SAVE_FILE="$2"
|
|
||||||
shift 2
|
|
||||||
else
|
|
||||||
die "Only one method can be passed."
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
die "Unrecognized argument: $1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# Screenshot functions
|
|
||||||
|
|
||||||
takeScreenshot() {
|
|
||||||
FILE="$1"
|
|
||||||
GEOM="$2"
|
|
||||||
|
|
||||||
ARGS=()
|
|
||||||
[ "$CURSOR" = "yes" ] && ARGS+=("-c")
|
|
||||||
[ -n "$GEOM" ] && ARGS+=("-g" "$GEOM")
|
|
||||||
ARGS+=("$FILE")
|
|
||||||
|
|
||||||
sleep "$DELAY"e-3
|
|
||||||
grim "${ARGS[@]}" || die "Unable to invoke grim"
|
|
||||||
}
|
|
||||||
|
|
||||||
takeEditedScreenshot() {
|
|
||||||
FILE="$1"
|
|
||||||
GEOM="$2"
|
|
||||||
|
|
||||||
if [ "$EDIT" = "yes" ]; then
|
|
||||||
takeScreenshot - "$GEOM" | swappy -f - -o "$FILE" || die "Unable to invoke swappy"
|
|
||||||
else
|
|
||||||
takeScreenshot "$FILE" "$GEOM"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Obtain the geometry for screenshot to be taken at
|
|
||||||
|
|
||||||
if [ "$TARGET" = "area" ]; then
|
|
||||||
GEOM="$(slurp -d)"
|
|
||||||
if [ -z "$GEOM" ]; then
|
|
||||||
die "No area selected" 2 normal
|
|
||||||
fi
|
|
||||||
WHAT="Area"
|
|
||||||
elif [ "$TARGET" = "all" ]; then
|
|
||||||
GEOM=""
|
|
||||||
WHAT="Screen"
|
|
||||||
elif [ "$TARGET" = "activewin" ]; then
|
|
||||||
FOCUSED="$(hyprctl activewindow -j)"
|
|
||||||
GEOM="$(echo "$FOCUSED" | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')"
|
|
||||||
APP_ID="$(echo "$FOCUSED" | jq -r '.class')"
|
|
||||||
WHAT="$APP_ID window"
|
|
||||||
elif [ "$TARGET" = "window" ]; then
|
|
||||||
WORKSPACES="$(hyprctl monitors -j | jq -r 'map(.activeWorkspace.id)')"
|
|
||||||
WINDOWS="$(hyprctl clients -j | jq -r --argjson workspaces "$WORKSPACES" 'map(select([.workspace.id] | inside($workspaces)))')"
|
|
||||||
GEOM=$(echo "$WINDOWS" | jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | slurp -r)
|
|
||||||
if [ -z "$GEOM" ]; then
|
|
||||||
die "No window selected" 2 normal
|
|
||||||
fi
|
|
||||||
WHAT="Window"
|
|
||||||
elif [ "$TARGET" = "activemon" ]; then
|
|
||||||
ACTIVEMON="$(hyprctl monitors -j | jq -r '.[] | select(.focused == true)')"
|
|
||||||
GEOM="$(echo "$ACTIVEMON" | jq -r '"\(.x),\(.y) \(.width)x\(.height)"')"
|
|
||||||
WHAT="$(echo "$ACTIVEMON" | jq -r '.name')"
|
|
||||||
elif [ "$TARGET" = "monitor" ]; then
|
|
||||||
GEOM="$(slurp -o)"
|
|
||||||
if [ -z "$GEOM" ]; then
|
|
||||||
die "No monitor selected" 2 normal
|
|
||||||
fi
|
|
||||||
WHAT="Monitor"
|
|
||||||
else
|
|
||||||
if [ -z "$TARGET" ]; then
|
|
||||||
die "No target specified!"
|
|
||||||
else
|
|
||||||
die "Unknown target: $SAVE_METHOD"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Invoke grim and capture the screenshot
|
|
||||||
|
|
||||||
if [ "$SAVE_METHOD" = "save" ]; then
|
|
||||||
takeEditedScreenshot "$SAVE_FILE" "$GEOM"
|
|
||||||
[ "$NOTIFY" = "yes" ] && notify-send -a screenshot "Success" "$WHAT screenshot saved" -i "$(realpath "$SAVE_FILE")"
|
|
||||||
elif [ "$SAVE_METHOD" = "copy" ]; then
|
|
||||||
TEMP_FILE="$(mktemp --suffix=.png)"
|
|
||||||
takeEditedScreenshot "-" "$GEOM" | tee "$TEMP_FILE" | wl-copy --type image/png || die "Clipboard error"
|
|
||||||
[ "$NOTIFY" = "yes" ] && notify-send -a screenshot "Success" "$WHAT screenshot copied" -i "$(realpath "$TEMP_FILE")" && rm "$TEMP_FILE"
|
|
||||||
elif [ "$SAVE_METHOD" = "copysave" ]; then
|
|
||||||
takeEditedScreenshot "-" "$GEOM" | tee "$SAVE_FILE" | wl-copy --type image/png || die "Clipboard error"
|
|
||||||
[ "$NOTIFY" = "yes" ] && notify-send -a screenshot "Success" "$WHAT screenshot copied and saved" -i "$(realpath "$SAVE_FILE")"
|
|
||||||
else
|
|
||||||
if [ -z "$SAVE_METHOD" ]; then
|
|
||||||
die "No save method specified!"
|
|
||||||
else
|
|
||||||
die "Unknown save method: $SAVE_METHOD"
|
|
||||||
fi
|
|
||||||
fi
|
|
|
@ -174,7 +174,6 @@
|
||||||
autoStart = true;
|
autoStart = true;
|
||||||
};
|
};
|
||||||
nomacs.enable = true;
|
nomacs.enable = true;
|
||||||
qbittorrent.enable = true;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,6 @@ in
|
||||||
autoStart = mkEnableOption "Auto-Start for Vesktop";
|
autoStart = mkEnableOption "Auto-Start for Vesktop";
|
||||||
};
|
};
|
||||||
nomacs.enable = mkEnableOption "Nomacs (Qt-based image viewer)";
|
nomacs.enable = mkEnableOption "Nomacs (Qt-based image viewer)";
|
||||||
qbittorrent.enable = mkEnableOption "Qbittorrent (Free software BitTorrent client)";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
tools = {
|
tools = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue