diff options
author | aszlig <aszlig@nix.build> | 2021-02-13 04:04:40 +0100 |
---|---|---|
committer | aszlig <aszlig@nix.build> | 2021-02-13 04:40:38 +0100 |
commit | 6ee8541db0196536c935cd8c82dca1991240d38e (patch) | |
tree | 63402221b32d18a3d57108a2db80bd5527cd7f36 /modules/user | |
parent | c7e86fadd27d30ebcf56cb311ce9661e5b244f2a (diff) |
profiles/workstation: Add Flameshot
So far I've almost exclusively used scrot for screenshots, but most of the time I used an image manipulation program to pixelate stuff, add descriptions or draw arrows. Flameshot combines this in a single application, so I expect that from now on I can spam-post screenshots in even a higher rate than before ;-) Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'modules/user')
-rw-r--r-- | modules/user/aszlig/profiles/workstation/default.nix | 1 | ||||
-rw-r--r-- | modules/user/aszlig/programs/flameshot/config.patch | 47 | ||||
-rw-r--r-- | modules/user/aszlig/programs/flameshot/default.nix | 52 | ||||
-rw-r--r-- | modules/user/aszlig/services/i3/default.nix | 4 | ||||
-rw-r--r-- | modules/user/aszlig/services/i3/i3.conf | 2 |
5 files changed, 106 insertions, 0 deletions
diff --git a/modules/user/aszlig/profiles/workstation/default.nix b/modules/user/aszlig/profiles/workstation/default.nix index 1935173c..e5591eeb 100644 --- a/modules/user/aszlig/profiles/workstation/default.nix +++ b/modules/user/aszlig/profiles/workstation/default.nix @@ -70,6 +70,7 @@ in { vuizvui.user.aszlig.services.vlock.enable = true; vuizvui.user.aszlig.services.vlock.user = "aszlig"; + vuizvui.user.aszlig.programs.flameshot.enable = true; vuizvui.user.aszlig.programs.mpv.enable = true; vuizvui.user.aszlig.programs.git.enable = true; diff --git a/modules/user/aszlig/programs/flameshot/config.patch b/modules/user/aszlig/programs/flameshot/config.patch new file mode 100644 index 00000000..6d01df12 --- /dev/null +++ b/modules/user/aszlig/programs/flameshot/config.patch @@ -0,0 +1,47 @@ +diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp +index ee50acb..8a92e08 100644 +--- a/src/utils/confighandler.cpp ++++ b/src/utils/confighandler.cpp +@@ -22,9 +22,8 @@ + #include <algorithm> + + ConfigHandler::ConfigHandler() +-{ +- m_settings.setDefaultFormat(QSettings::IniFormat); +-} ++ : m_settings("@configFile@", QSettings::IniFormat) ++{} + + QVector<CaptureToolButton::ButtonType> ConfigHandler::getButtons() + { +@@ -55,9 +54,7 @@ QVector<CaptureToolButton::ButtonType> ConfigHandler::getButtons() + << CaptureToolButton::TYPE_UNDO << CaptureToolButton::TYPE_REDO + << CaptureToolButton::TYPE_COPY << CaptureToolButton::TYPE_SAVE + << CaptureToolButton::TYPE_EXIT +- << CaptureToolButton::TYPE_IMAGEUPLOADER +- << CaptureToolButton::TYPE_OPEN_APP +- << CaptureToolButton::TYPE_PIN << CaptureToolButton::TYPE_TEXT ++ << CaptureToolButton::TYPE_TEXT + << CaptureToolButton::TYPE_CIRCLECOUNT; + } + +@@ -119,7 +116,8 @@ void ConfigHandler::setUserColors(const QVector<QColor>& l) + + QString ConfigHandler::savePathValue() + { +- return m_settings.value(QStringLiteral("savePath")).toString(); ++ return m_settings.value(QStringLiteral("savePath")).toString() ++ .replace("$HOME", QDir::homePath()); + } + + void ConfigHandler::setSavePath(const QString& savePath) +@@ -390,7 +388,8 @@ void ConfigHandler::setSaveAfterCopy(const bool save) + + QString ConfigHandler::saveAfterCopyPathValue() + { +- return m_settings.value(QStringLiteral("saveAfterCopyPath")).toString(); ++ return m_settings.value(QStringLiteral("saveAfterCopyPath")).toString() ++ .replace("$HOME", QDir::homePath()); + } + + void ConfigHandler::setSaveAfterCopyPath(const QString& path) diff --git a/modules/user/aszlig/programs/flameshot/default.nix b/modules/user/aszlig/programs/flameshot/default.nix new file mode 100644 index 00000000..29bb638d --- /dev/null +++ b/modules/user/aszlig/programs/flameshot/default.nix @@ -0,0 +1,52 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.vuizvui.user.aszlig.programs.flameshot; + + # TODO: Make configurable via module system. + settings = { + closeAfterScreenshot = true; + disabledTrayIcon = true; + drawColor = "#ff0000"; + drawThickness = 2; + saveAfterCopyPath = "$HOME/screenshots"; + savePath = "$HOME/screenshots"; + savePathFixed = true; + }; + +in { + options.vuizvui.user.aszlig.programs.flameshot = { + enable = lib.mkEnableOption "Flameshot"; + + package = lib.mkOption { + type = lib.types.package; + default = pkgs.flameshot.overrideAttrs (drv: { + patches = (drv.patches or []) ++ lib.singleton ./config.patch; + configFile = pkgs.writeText "flameshot.ini" (lib.generators.toINI {} { + General = settings; + }); + postPatch = (drv.postPatch or "") + '' + substituteInPlace src/utils/confighandler.cpp --subst-var configFile + ''; + }); + readOnly = true; + internal = true; + description = "The patched Flameshot package."; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = lib.singleton cfg.package; + + services.dbus.packages = lib.singleton (pkgs.writeTextFile { + name = "flameshot-dbus"; + destination = "/share/dbus-1/services/org.flameshot.Flameshot.service"; + text = lib.generators.toINI {} { + "D-BUS Service" = { + Name = "org.flameshot.Flameshot"; + Exec = "${cfg.package}/bin/flameshot"; + }; + }; + }); + }; +} diff --git a/modules/user/aszlig/services/i3/default.nix b/modules/user/aszlig/services/i3/default.nix index 733541ee..d11140dd 100644 --- a/modules/user/aszlig/services/i3/default.nix +++ b/modules/user/aszlig/services/i3/default.nix @@ -117,6 +117,10 @@ in inherit (pkgs.xorg) xsetroot; inherit wsConfig barConfig; + # XXX: Decouple this by making the i3 bindsym directives available to + # the NixOS module system. + flameshot = config.vuizvui.user.aszlig.programs.flameshot.package; + lockall = pkgs.writeScript "lockvt.sh" '' #!${pkgs.stdenv.shell} "${pkgs.socat}/bin/socat" - UNIX-CONNECT:/run/console-lock.sock \ diff --git a/modules/user/aszlig/services/i3/i3.conf b/modules/user/aszlig/services/i3/i3.conf index 6e9307f2..1f5246fe 100644 --- a/modules/user/aszlig/services/i3/i3.conf +++ b/modules/user/aszlig/services/i3/i3.conf @@ -84,6 +84,8 @@ bindsym $mod+Shift+R restart # exit i3 (logs you out of your X session) bindsym $mod+Shift+Q exit +bindsym Print exec @flameshot@/bin/flameshot gui + # resize window (you can also use the mouse for that) mode "resize" { # These bindings trigger as soon as you enter the resize mode |