From 1b526ec1a597882b7629e992c7579ee109282aa7 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 8 Feb 2019 17:46:32 +0100 Subject: flameshot-once: add config --- krebs/5pkgs/simple/flameshot-once/profile.nix | 123 ++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 krebs/5pkgs/simple/flameshot-once/profile.nix (limited to 'krebs/5pkgs/simple/flameshot-once/profile.nix') diff --git a/krebs/5pkgs/simple/flameshot-once/profile.nix b/krebs/5pkgs/simple/flameshot-once/profile.nix new file mode 100644 index 00000000..bfe571ff --- /dev/null +++ b/krebs/5pkgs/simple/flameshot-once/profile.nix @@ -0,0 +1,123 @@ +with import ; +{ config, pkgs }: +let + + # Refs https://github.com/lupoDharkael/flameshot/blob/master/src/widgets/capture/capturebutton.h + ButtonType = { + PENCIL = 0; + DRAWER = 1; + ARROW = 2; + SELECTION = 3; + RECTANGLE = 4; + CIRCLE = 5; + MARKER = 6; + SELECTIONINDICATOR = 7; + MOVESELECTION = 8; + UNDO = 9; + COPY = 10; + SAVE = 11; + EXIT = 12; + IMAGEUPLOADER = 13; + OPEN_APP = 14; + BLUR = 15; + REDO = 16; + PIN = 17; + TEXT = 18; + }; + + cfg = eval.config; + + eval = evalModules { + modules = singleton { + _file = toString ./config.nix; + imports = singleton config; + options = { + buttons = mkOption { + apply = map (name: ButtonType.${name}); + default = [ + "PENCIL" + "DRAWER" + "ARROW" + "SELECTION" + "RECTANGLE" + "CIRCLE" + "MARKER" + "SELECTIONINDICATOR" + "MOVESELECTION" + "UNDO" + "COPY" + "SAVE" + "EXIT" + "BLUR" + ]; + type = types.listOf (types.enum (attrNames ButtonType)); + }; + disabledTrayIcon = mkOption { + default = true; + type = types.bool; + }; + drawThickness = mkOption { + default = 8; + type = types.positive; + }; + savePath = mkOption { + default = "/tmp"; + type = types.absolute-pathname; + }; + showDesktopNotification = mkOption { + default = false; + type = types.bool; + }; + showHelp = mkOption { + default = false; + type = types.bool; + }; + }; + }; + }; + + hexchars = stringToCharacters "0123456789abcdef"; + + # Encode integer to C-escaped string of bytes, little endian / LSB 0 + le = rec { + x1 = i: let + i0 = mod i 16; + i1 = i / 16; + in + "\\x${elemAt hexchars i1}${elemAt hexchars i0}"; + + x2 = i: let + i0 = mod i 256; + i1 = i / 256; + in + "${x1 i0}${x1 i1}"; + + x4 = i: let + i0 = mod i 65536; + i1 = i / 65536; + in + "${x2 i0}${x2 i1}"; + }; + + toQList = t: xs: + assert t == "int"; + "QList<${t}>${le.x4 0}${le.x4 (length xs)}${concatMapStrings le.x4 xs}"; + + XDG_CONFIG_HOME = pkgs.write "flameshot-config" { + "/Dharkael/flameshot.ini".text = '' + [General] + buttons=@Variant(\0\0\0\x7f\0\0\0\v${toQList "int" cfg.buttons}) + disabledTrayIcon=${toJSON cfg.disabledTrayIcon} + drawThickness=${toJSON cfg.drawThickness} + savePath=${toJSON cfg.savePath} + showDesktopNotification=${toJSON cfg.showDesktopNotification} + showHelp=${toJSON cfg.showHelp} + ''; + }; + +in + + pkgs.writeDash "flameshot.profile" '' + export FLAMESHOT_CAPTURE_PATH=${cfg.savePath} + export XDG_CONFIG_HOME=${XDG_CONFIG_HOME} + '' -- cgit v1.2.3 From f9496394975782a3aee0998a9a6d5882b67c0901 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 9 Feb 2019 02:34:32 +0100 Subject: flameshot-once: make filenamePattern configurable --- krebs/5pkgs/simple/flameshot-once/profile.nix | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'krebs/5pkgs/simple/flameshot-once/profile.nix') diff --git a/krebs/5pkgs/simple/flameshot-once/profile.nix b/krebs/5pkgs/simple/flameshot-once/profile.nix index bfe571ff..69adb240 100644 --- a/krebs/5pkgs/simple/flameshot-once/profile.nix +++ b/krebs/5pkgs/simple/flameshot-once/profile.nix @@ -60,6 +60,12 @@ let default = 8; type = types.positive; }; + filenamePattern = mkOption { + default = "%FT%T%z_flameshot.png"; + type = + # This is types.filename extended by [%:][%:+]* + types.addCheck types.str (test "[%:0-9A-Za-z._][%:+0-9A-Za-z._-]*"); + }; savePath = mkOption { default = "/tmp"; type = types.absolute-pathname; @@ -109,6 +115,7 @@ let buttons=@Variant(\0\0\0\x7f\0\0\0\v${toQList "int" cfg.buttons}) disabledTrayIcon=${toJSON cfg.disabledTrayIcon} drawThickness=${toJSON cfg.drawThickness} + filenamePattern=${toJSON cfg.filenamePattern} savePath=${toJSON cfg.savePath} showDesktopNotification=${toJSON cfg.showDesktopNotification} showHelp=${toJSON cfg.showHelp} -- cgit v1.2.3 From e29debea42379fcb529057edf1963928466b0181 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 9 Feb 2019 02:33:58 +0100 Subject: flameshot-once: 1.0.1 -> 1.1.0 --- krebs/5pkgs/simple/flameshot-once/profile.nix | 1 - 1 file changed, 1 deletion(-) (limited to 'krebs/5pkgs/simple/flameshot-once/profile.nix') diff --git a/krebs/5pkgs/simple/flameshot-once/profile.nix b/krebs/5pkgs/simple/flameshot-once/profile.nix index 69adb240..4fcbd62c 100644 --- a/krebs/5pkgs/simple/flameshot-once/profile.nix +++ b/krebs/5pkgs/simple/flameshot-once/profile.nix @@ -45,7 +45,6 @@ let "SELECTIONINDICATOR" "MOVESELECTION" "UNDO" - "COPY" "SAVE" "EXIT" "BLUR" -- cgit v1.2.3 From 4e81d40e30ef2582d4566af171066bd675af7aa2 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 16 Feb 2019 17:47:12 +0100 Subject: flameshot-once: default filenamePattern w/o .png --- krebs/5pkgs/simple/flameshot-once/profile.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'krebs/5pkgs/simple/flameshot-once/profile.nix') diff --git a/krebs/5pkgs/simple/flameshot-once/profile.nix b/krebs/5pkgs/simple/flameshot-once/profile.nix index 4fcbd62c..7373da00 100644 --- a/krebs/5pkgs/simple/flameshot-once/profile.nix +++ b/krebs/5pkgs/simple/flameshot-once/profile.nix @@ -60,7 +60,7 @@ let type = types.positive; }; filenamePattern = mkOption { - default = "%FT%T%z_flameshot.png"; + default = "%FT%T%z_flameshot"; type = # This is types.filename extended by [%:][%:+]* types.addCheck types.str (test "[%:0-9A-Za-z._][%:+0-9A-Za-z._-]*"); -- cgit v1.2.3