summaryrefslogtreecommitdiffstats
path: root/pkgs/simple/flameshot-once/config.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-02 03:09:31 +0000
committertv <tv@krebsco.de>2026-12-02 03:09:31 +0000
commit3bcd7cfb246c84de600802b750157ae560a712c6 (patch)
tree5bbec0ac8e57747cf6a39151609c1b284e8d506a /pkgs/simple/flameshot-once/config.nix
parent41540f13a300834ddba0e0ef708ee493c86c5092 (diff)
flameshot-once: buttons
The option that was commented out, back, with its encoding as QSettings reads it (QList<int> in a @Variant), and the tools that list the button types, which generated the tables for flameshot 15: TYPE_INVERT is iterable now, and get-iterableButtonTypes defines ENABLE_IMGUR, as our flameshot does.
Diffstat (limited to 'pkgs/simple/flameshot-once/config.nix')
-rw-r--r--pkgs/simple/flameshot-once/config.nix111
1 files changed, 111 insertions, 0 deletions
diff --git a/pkgs/simple/flameshot-once/config.nix b/pkgs/simple/flameshot-once/config.nix
index 2d8a9dc7..3738dc1e 100644
--- a/pkgs/simple/flameshot-once/config.nix
+++ b/pkgs/simple/flameshot-once/config.nix
@@ -1,5 +1,39 @@
{ config, lib, mylib, pkgs, ... }:
+let
+ toHexchar = builtins.elemAt mylib.hexchars;
+
+ # Encode integer to C-escaped string of bytes, little endian / LSB 0
+ le = rec {
+ x1 = i: let
+ i0 = lib.mod i 16;
+ i1 = i / 16;
+ in
+ if i == 0 then
+ "\\0"
+ else if i < 16 then
+ "\\x${toHexchar i0}"
+ else
+ "\\x${toHexchar i1}${toHexchar i0}";
+
+ x2 = i: let
+ i0 = lib.mod i 256;
+ i1 = i / 256;
+ in
+ "${x1 i1}${x1 i0}";
+
+ x4 = i: let
+ i0 = lib.mod i 65536;
+ i1 = i / 65536;
+ in
+ "${x2 i1}${x2 i0}";
+ };
+
+ toQList = t: xs:
+ assert t == "int";
+ "QList<${t}>${le.x4 0}${le.x1 (builtins.length xs)}${lib.concatMapStrings le.x4 xs}";
+in
+
{
options = {
imgur = lib.mkOption {
@@ -73,6 +107,83 @@
'';
type = lib.types.nullOr lib.types.bool;
};
+ buttons = let
+ buttonTypes = {
+ # Generated with:
+ # nix-shell -p flameshot-once.dev --run get-buttonTypes
+ TYPE_PENCIL = 0;
+ TYPE_DRAWER = 1;
+ TYPE_ARROW = 2;
+ TYPE_SELECTION = 3;
+ TYPE_RECTANGLE = 4;
+ TYPE_CIRCLE = 5;
+ TYPE_MARKER = 6;
+ TYPE_MOVESELECTION = 8;
+ TYPE_UNDO = 9;
+ TYPE_COPY = 10;
+ TYPE_SAVE = 11;
+ TYPE_EXIT = 12;
+ TYPE_IMAGEUPLOADER = 13;
+ TYPE_OPEN_APP = 14;
+ TYPE_PIXELATE = 15;
+ TYPE_REDO = 16;
+ TYPE_PIN = 17;
+ TYPE_TEXT = 18;
+ TYPE_CIRCLECOUNT = 19;
+ TYPE_SIZEINCREASE = 20;
+ TYPE_SIZEDECREASE = 21;
+ TYPE_INVERT = 22;
+ TYPE_ACCEPT = 23;
+ TYPE_CANCEL = 24;
+ };
+ iterableButtonTypes = [
+ # Generated with:
+ # nix-shell -p flameshot-once.dev --run get-iterableButtonTypes
+ "TYPE_ACCEPT"
+ "TYPE_ARROW"
+ "TYPE_CIRCLE"
+ "TYPE_CIRCLECOUNT"
+ "TYPE_COPY"
+ "TYPE_DRAWER"
+ "TYPE_EXIT"
+ "TYPE_IMAGEUPLOADER"
+ "TYPE_INVERT"
+ "TYPE_MARKER"
+ "TYPE_MOVESELECTION"
+ "TYPE_OPEN_APP"
+ "TYPE_PENCIL"
+ "TYPE_PIN"
+ "TYPE_PIXELATE"
+ "TYPE_RECTANGLE"
+ "TYPE_REDO"
+ "TYPE_SAVE"
+ "TYPE_SELECTION"
+ "TYPE_SIZEDECREASE"
+ "TYPE_SIZEINCREASE"
+ "TYPE_TEXT"
+ "TYPE_UNDO"
+ ];
+ in lib.mkOption {
+ # apply :: [int] -> str
+ # where str is readable by QSettingsPrivate::stringToVariant[1]
+ #
+ # [1]: https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/io/qsettings.cpp?id=ab9f5a9#n454
+ apply = names:
+ if names != null then let
+ values = map (name: buttonTypes.${name}) names;
+ in
+ # 127 11
+ ''@Variant(\0\0\0\x7f\0\0\0\v${toQList "int" values})''
+ else
+ null;
+ description = ''
+ Configure which buttons to show after drawing a selection
+ '';
+ type =
+ lib.types.nullOr
+ (lib.types.listOf
+ (lib.types.enum iterableButtonTypes));
+ };
captureActiveMonitor = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
};