From 183c97f9928cf4925c6f44377fa95ecc5c7251b1 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 21 Jun 2024 11:44:56 +0200 Subject: [PATCH 1/3] Add qbittorrent --- home/packages/gui/default.nix | 1 + home/packages/gui/qbittorrent.nix | 17 +++++++++++++++++ hosts/voyager/default.nix | 1 + options/home/programs/default.nix | 1 + 4 files changed, 20 insertions(+) create mode 100644 home/packages/gui/qbittorrent.nix diff --git a/home/packages/gui/default.nix b/home/packages/gui/default.nix index 9c7f80c..cbc8417 100644 --- a/home/packages/gui/default.nix +++ b/home/packages/gui/default.nix @@ -3,5 +3,6 @@ _: { ./wayland.nix ./stremio.nix ./nomacs.nix + ./qbittorrent.nix ]; } diff --git a/home/packages/gui/qbittorrent.nix b/home/packages/gui/qbittorrent.nix new file mode 100644 index 0000000..2275b25 --- /dev/null +++ b/home/packages/gui/qbittorrent.nix @@ -0,0 +1,17 @@ +{ + 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 + ]; + }; +} + diff --git a/hosts/voyager/default.nix b/hosts/voyager/default.nix index 1052e46..29a6a30 100644 --- a/hosts/voyager/default.nix +++ b/hosts/voyager/default.nix @@ -174,6 +174,7 @@ autoStart = true; }; nomacs.enable = true; + qbittorrent.enable = true; }; }; }; diff --git a/options/home/programs/default.nix b/options/home/programs/default.nix index 4a91423..f602885 100644 --- a/options/home/programs/default.nix +++ b/options/home/programs/default.nix @@ -34,6 +34,7 @@ in autoStart = mkEnableOption "Auto-Start for Vesktop"; }; nomacs.enable = mkEnableOption "Nomacs (Qt-based image viewer)"; + qbittorrent.enable = mkEnableOption "Qbittorrent (Free software BitTorrent client)"; }; tools = { From c2ddd6e720ee86f8b601b1ba7974c45ab29993ef Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 21 Jun 2024 11:52:39 +0200 Subject: [PATCH 2/3] Add wayland applications for screenshot/video taking --- home/packages/cli/wayland.nix | 30 +++++++++++++++++++++++++++++- home/packages/gui/wayland.nix | 3 ++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/home/packages/cli/wayland.nix b/home/packages/cli/wayland.nix index 7e3c31e..3dbf6d9 100644 --- a/home/packages/cli/wayland.nix +++ b/home/packages/cli/wayland.nix @@ -8,7 +8,35 @@ in { config = mkIf osConfig.myOptions.home-manager.wms.isWayland { home.packages = with pkgs; [ - wl-clipboard + wl-clipboard # clipboard interactions + 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' Date: Fri, 21 Jun 2024 12:19:03 +0200 Subject: [PATCH 3/3] Add screenshot support --- .../wms/hyprland/config/keybinds.nix | 21 +- .../graphical/wms/hyprland/default.nix | 2 + .../wms/hyprland/packages/default.nix | 1 + .../packages/hyprland-screenshot/default.nix | 24 ++ .../hyprland-screenshot.sh | 216 ++++++++++++++++++ 5 files changed, 262 insertions(+), 2 deletions(-) create mode 100644 home/programs/graphical/wms/hyprland/packages/hyprland-screenshot/default.nix create mode 100644 home/programs/graphical/wms/hyprland/packages/hyprland-screenshot/hyprland-screenshot.sh diff --git a/home/programs/graphical/wms/hyprland/config/keybinds.nix b/home/programs/graphical/wms/hyprland/config/keybinds.nix index 91bfa5a..9b3143f 100644 --- a/home/programs/graphical/wms/hyprland/config/keybinds.nix +++ b/home/programs/graphical/wms/hyprland/config/keybinds.nix @@ -1,4 +1,4 @@ -{ +{ config, ... }: { wayland.windowManager.hyprland = { settings = { "$MOUSE_LMB" = "mouse:272"; @@ -9,6 +9,9 @@ "$XF86Favorites" = "164"; + "$SCREENSHOT_FORMAT" = "${config.xdg.userDirs.extraConfig.XDG_SCREENSHOTS_DIR}/Screenshot_''$(date +%Y-%m-%d_%H-%M-%S).png"; + "$SCREENSHOT_DELAY" = "2000"; + bind = [ # # Active window @@ -36,7 +39,21 @@ # # Screenshots # - # TODO: requires script + "ALT, Print, exec, wl-copy \"$(hyprpicker)\" && notify-send 'Picked color' \"$(wl-paste) (saved to clipboard)\"" + ", 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 diff --git a/home/programs/graphical/wms/hyprland/default.nix b/home/programs/graphical/wms/hyprland/default.nix index 7b1ce94..fac274d 100644 --- a/home/programs/graphical/wms/hyprland/default.nix +++ b/home/programs/graphical/wms/hyprland/default.nix @@ -17,7 +17,9 @@ in { config = mkIf cfg.enable { home.packages = [ hyprPkgs.hyprland-move-window + hyprPkgs.hyprland-screenshot pkgs.brightnessctl + pkgs.hyprpicker hyprPkgs.brightness ]; diff --git a/home/programs/graphical/wms/hyprland/packages/default.nix b/home/programs/graphical/wms/hyprland/packages/default.nix index f5c76ee..c3d2e3a 100644 --- a/home/programs/graphical/wms/hyprland/packages/default.nix +++ b/home/programs/graphical/wms/hyprland/packages/default.nix @@ -5,6 +5,7 @@ packages = { hyprland-move-window = pkgs.callPackage ./hyprland-move-window {}; brightness = pkgs.callPackage ./brightness {}; + hyprland-screenshot = pkgs.callPackage ./hyprland-screenshot {}; }; in packages diff --git a/home/programs/graphical/wms/hyprland/packages/hyprland-screenshot/default.nix b/home/programs/graphical/wms/hyprland/packages/hyprland-screenshot/default.nix new file mode 100644 index 0000000..06cfe2e --- /dev/null +++ b/home/programs/graphical/wms/hyprland/packages/hyprland-screenshot/default.nix @@ -0,0 +1,24 @@ +# - `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} + ''; +} diff --git a/home/programs/graphical/wms/hyprland/packages/hyprland-screenshot/hyprland-screenshot.sh b/home/programs/graphical/wms/hyprland/packages/hyprland-screenshot/hyprland-screenshot.sh new file mode 100644 index 0000000..a48af52 --- /dev/null +++ b/home/programs/graphical/wms/hyprland/packages/hyprland-screenshot/hyprland-screenshot.sh @@ -0,0 +1,216 @@ +#!/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 <