{ 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 { default = {}; type = lib.types.submodule { options = { enable = lib.mkEnableOption "imgur"; createUrl = lib.mkOption { example = "http://p.r/image"; type = lib.types.str; }; deleteUrl = lib.mkOption { example = "http://p.r/image/delete/%1"; type = lib.types.str; }; xdg-open = lib.mkOption { default = {}; type = lib.types.submodule { options = { enable = lib.mkEnableOption "imgur.xdg-open" // { default = true; }; browser = lib.mkOption { default = "${pkgs.coreutils}/bin/false"; type = lib.types.str; }; createPrefix = lib.mkOption { default = config.imgur.createUrl; type = lib.types.str; }; deletePrefix = lib.mkOption { default = lib.removeSuffix "/%1" config.imgur.deleteUrl; type = lib.types.str; }; }; }; }; }; }; }; package = lib.mkOption { type = lib.types.package; default = import ./flameshot pkgs pkgs; }; settings = { # Options without a description are not documented in flameshot's README. # Compare with: # nix-shell -p flameshot-once.dev --run get-recognizedGeneralOptions General = lib.mapAttrs (_: lib.recursiveUpdate { default = null; }) { allowMultipleGuiInstances = lib.mkOption { description = '' Allow multiple instances of `flameshot gui` to run at the same time ''; type = lib.types.nullOr lib.types.bool; }; antialiasingPinZoom = lib.mkOption { description = '' Anti-aliasing image when zoom the pinned image ''; type = lib.types.nullOr lib.types.bool; }; arrowStyle = lib.mkOption { description = '' Arrow style: 0 = default, 1 = curved ''; type = lib.types.nullOr (mylib.types.boundedInt 0 1); }; autoCloseIdleDaemon = lib.mkOption { description = '' Automatically close daemon when it's not needed ''; 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; }; contrastOpacity = lib.mkOption { description = '' Opacity of area outside selection ''; type = lib.types.nullOr (mylib.types.boundedInt 0 255); }; contrastUiColor = lib.mkOption { description = '' Contrast UI color ''; type = lib.types.nullOr mylib.types.flameshot.color; }; copyOnDoubleClick = lib.mkOption { type = lib.types.nullOr lib.types.bool; }; copyPathAfterSave = lib.mkOption { description = '' Copy path to image after save ''; type = lib.types.nullOr lib.types.bool; }; copyURLAfterUpload = lib.mkOption { description = '' On successful upload, close the dialog and copy URL to clipboard ''; type = lib.types.nullOr lib.types.bool; }; disabledTrayIcon = lib.mkOption { description = '' Whether the tray icon is disabled ''; type = lib.types.nullOr lib.types.bool; }; drawCircleCounterOutline = lib.mkOption { description = '' Draw a contrasting outline ring around the Circle Counter bubble ''; type = lib.types.nullOr lib.types.bool; }; drawCircleCounterSize = lib.mkOption { description = '' Last used Circle Counter size ''; type = lib.types.nullOr mylib.types.positive; }; drawColor = lib.mkOption { description = '' Last used color ''; type = lib.types.nullOr mylib.types.flameshot.color; }; drawFontSize = lib.mkOption { type = lib.types.nullOr mylib.types.positive; }; drawMarkerSize = lib.mkOption { description = '' Last used Marker size ''; type = lib.types.nullOr mylib.types.positive; }; drawPixelateSize = lib.mkOption { description = '' Last used Pixelate pixel size ''; type = lib.types.nullOr mylib.types.positive; }; drawRectangleSize = lib.mkOption { description = '' Last used size for Rectangle rounded corners ''; type = lib.types.nullOr mylib.types.positive; }; drawThickness = lib.mkOption { description = '' Last used tool thickness ''; type = lib.types.nullOr mylib.types.positive; }; filenamePattern = lib.mkOption { description = '' Filename pattern using C++ strftime formatting ''; type = lib.types.nullOr # This is types.filename extended by [%:][%:+]* (lib.types.addCheck lib.types.str (mylib.test "[%:0-9A-Za-z._][%:+0-9A-Za-z._-]*")); }; fontFamily = lib.mkOption { type = lib.types.nullOr lib.types.str; }; historyConfirmationToDelete = lib.mkOption { type = lib.types.nullOr lib.types.bool; }; ignoreUpdateToVersion = lib.mkOption { description = '' Ignore updates to versions less than this value ''; type = lib.types.nullOr lib.types.str; }; insecurePixelate = lib.mkOption { type = lib.types.nullOr lib.types.bool; }; jpegQuality = lib.mkOption { description = '' Set JPEG Quality ''; type = lib.types.nullOr (mylib.types.boundedInt 0 100); }; keepOpenAppLauncher = lib.mkOption { description = '' Keep the App Launcher open after selecting an app ''; type = lib.types.nullOr lib.types.bool; }; predefinedColorPaletteLarge = lib.mkOption { description = '' Use larger color palette as the default one ''; type = lib.types.nullOr lib.types.bool; }; reverseArrow = lib.mkOption { type = lib.types.nullOr lib.types.bool; }; saveAfterCopy = lib.mkOption { description = '' Save image after copy ''; type = lib.types.nullOr lib.types.bool; }; saveAsFileExtension = lib.mkOption { description = '' Default file extension for screenshots ''; type = lib.types.nullOr (lib.types.addCheck mylib.types.filename (lib.hasPrefix ".")); }; saveLastRegion = lib.mkOption { type = lib.types.nullOr lib.types.bool; }; savePath = lib.mkOption { description = '' Image Save Path ''; type = lib.types.nullOr mylib.types.absolute-pathname; }; savePathFixed = lib.mkOption { description = '' Whether the savePath is a fixed path ''; type = lib.types.nullOr lib.types.bool; }; showAbortNotification = lib.mkOption { description = '' Show abort notifications ''; type = lib.types.nullOr lib.types.bool; }; showDesktopNotification = lib.mkOption { description = '' Show desktop notifications ''; type = lib.types.nullOr lib.types.bool; }; showHelp = lib.mkOption { description = '' Show the help screen on startup ''; type = lib.types.nullOr lib.types.bool; }; showMagnifier = lib.mkOption { type = lib.types.nullOr lib.types.bool; }; showQuitPrompt = lib.mkOption { type = lib.types.nullOr lib.types.bool; }; showSelectionGeometry = lib.mkOption { type = lib.types.nullOr (mylib.types.boundedInt 0 5); }; showSelectionGeometryHideTime = lib.mkOption { type = lib.types.nullOr mylib.types.uint; }; showSidePanelButton = lib.mkOption { description = '' Show the side panel button ''; type = lib.types.nullOr lib.types.bool; }; showStartupLaunchMessage = lib.mkOption { type = lib.types.nullOr lib.types.bool; }; squareMagnifier = lib.mkOption { type = lib.types.nullOr lib.types.bool; }; startupLaunch = lib.mkOption { description = '' Launch at startup ''; type = lib.types.nullOr lib.types.bool; }; uiColor = lib.mkOption { description = '' Main UI color ''; type = lib.types.nullOr mylib.types.flameshot.color; }; uiLanguage = lib.mkOption { description = '' UI language (auto = detected system language) ''; type = lib.types.nullOr lib.types.str; }; undoLimit = lib.mkOption { type = lib.types.nullOr (mylib.types.boundedInt 0 999); }; uploadClientSecret = lib.mkOption { type = lib.types.nullOr lib.types.str; }; uploadHistoryMax = lib.mkOption { type = lib.types.nullOr mylib.types.uint; }; uploadWithoutConfirmation = lib.mkOption { description = '' Upload to imgur without confirmation ''; type = lib.types.nullOr lib.types.bool; }; useJpgForClipboard = lib.mkOption { description = '' Use JPG format instead of PNG ''; type = lib.types.nullOr lib.types.bool; }; useX11LegacyScreenshot = lib.mkOption { description = '' [Deprecated] Use legacy Qt X11 screenshot method instead of freedesktop portal. Enable this if your WM has no xdg-desktop-portal (e.g. xmonad, i3). Only effective on X11; ignored on Wayland. ''; type = lib.types.nullOr lib.types.bool; }; userColors = lib.mkOption { apply = value: if value != null then lib.concatStringsSep ", " value else null; description = '' List of colors for color picker The colors are arranged counter-clockwise with the first being set to the right of the cursor. "picker" adds a custom color picker. ''; type = lib.types.nullOr (lib.types.listOf (lib.types.either mylib.types.flameshot.color (lib.types.enum ["picker"]))); }; }; Shortcuts = lib.genAttrs [ # Generated with: # nix-shell -p flameshot-once.dev --run get-Shortcuts "TYPE_ACCEPT" "TYPE_ARROW" "TYPE_CANCEL" "TYPE_CIRCLE" "TYPE_CIRCLECOUNT" "TYPE_CLOSE_ACTIVE_PIN_WINDOW" "TYPE_COMMIT_CURRENT_TOOL" "TYPE_COPY" "TYPE_DELETE_CURRENT_TOOL" "TYPE_DRAWER" "TYPE_EXIT" "TYPE_GRAB_COLOR" "TYPE_IMAGEUPLOADER" "TYPE_INVERT" "TYPE_MARKER" "TYPE_MOVESELECTION" "TYPE_MOVE_DOWN" "TYPE_MOVE_LEFT" "TYPE_MOVE_RIGHT" "TYPE_MOVE_UP" "TYPE_OPEN_APP" "TYPE_PENCIL" "TYPE_PIN" "TYPE_PIXELATE" "TYPE_RECTANGLE" "TYPE_REDO" "TYPE_RESIZE_DOWN" "TYPE_RESIZE_LEFT" "TYPE_RESIZE_RIGHT" "TYPE_RESIZE_UP" "TYPE_SAVE" "TYPE_SELECTION" "TYPE_SELECT_ALL" "TYPE_SIZEDECREASE" "TYPE_SIZEINCREASE" "TYPE_SYM_RESIZE_DOWN" "TYPE_SYM_RESIZE_LEFT" "TYPE_SYM_RESIZE_RIGHT" "TYPE_SYM_RESIZE_UP" "TYPE_TEXT" "TYPE_TOGGLE_PANEL" "TYPE_UNDO" ] (name: lib.mkOption { default = null; type = lib.types.nullOr lib.types.str; }); }; }; }