diff options
author | tv <tv@krebsco.de> | 2020-05-01 23:51:47 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2020-05-05 17:49:28 +0200 |
commit | 66a3597034c0f400a948b551e95234f94c227859 (patch) | |
tree | e199f121f2fdc2a8cf4401b0e46ce7b75515f49f /krebs/5pkgs | |
parent | b6c670fea48a52492f50d1ed0713b3817891a123 (diff) |
flameshot-once: add imgur support
Diffstat (limited to 'krebs/5pkgs')
-rw-r--r-- | krebs/5pkgs/simple/flameshot-once/profile.nix | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/krebs/5pkgs/simple/flameshot-once/profile.nix b/krebs/5pkgs/simple/flameshot-once/profile.nix index 8ea8a850c..4427e5b23 100644 --- a/krebs/5pkgs/simple/flameshot-once/profile.nix +++ b/krebs/5pkgs/simple/flameshot-once/profile.nix @@ -48,7 +48,9 @@ let "SAVE" "EXIT" "BLUR" - ]; + ] + ++ optional cfg.imgur.enable "IMAGEUPLOADER" + ; type = types.listOf (types.enum (attrNames ButtonType)); }; disabledTrayIcon = mkOption { @@ -65,6 +67,44 @@ let # This is types.filename extended by [%:][%:+]* types.addCheck types.str (test "[%:0-9A-Za-z._][%:+0-9A-Za-z._-]*"); }; + imgur = mkOption { + default = {}; + type = types.submodule { + options = { + enable = mkEnableOption "imgur"; + createUrl = mkOption { + example = "http://p.r/image"; + type = types.str; + }; + deleteUrl = mkOption { + example = "http://p.r/image/delete/%1"; + type = types.str; + }; + xdg-open = mkOption { + default = {}; + type = types.submodule { + options = { + enable = mkEnableOption "imgur.xdg-open" // { + default = true; + }; + browser = mkOption { + default = "${pkgs.coreutils}/bin/false"; + type = types.str; + }; + createPrefix = mkOption { + default = cfg.imgur.createUrl; + type = types.str; + }; + deletePrefix = mkOption { + default = removeSuffix "/%1" cfg.imgur.deleteUrl; + type = types.str; + }; + }; + }; + }; + }; + }; + }; savePath = mkOption { default = "/tmp"; type = types.absolute-pathname; @@ -135,4 +175,30 @@ in export FLAMESHOT_CAPTURE_PATH=${cfg.savePath} export FLAMESHOT_ONCE_TIMEOUT=${toString cfg.timeout} export XDG_CONFIG_HOME=${XDG_CONFIG_HOME} + ${optionalString cfg.imgur.enable /* sh */ '' + export IMGUR_CREATE_URL=${shell.escape cfg.imgur.createUrl} + export IMGUR_DELETE_URL=${shell.escape cfg.imgur.deleteUrl} + ${optionalString cfg.imgur.xdg-open.enable /* sh */ '' + PATH=$PATH:${makeBinPath [ + (pkgs.writeDashBin "xdg-open" '' + set -efu + uri=$1 + prefix=$(${pkgs.coreutils}/bin/dirname "$uri") + case $prefix in + (${shell.escape cfg.imgur.xdg-open.createPrefix}) + echo "opening image in browser: $uri" >&2 + exec ${config.imgur.xdg-open.browser} "$uri" + ;; + (${shell.escape cfg.imgur.xdg-open.deletePrefix}) + echo "deleting image: $uri" >&2 + exec ${pkgs.curl}/bin/curl -fsS -X DELETE "$uri" + ;; + (*) + echo "don't know how to open URI: $uri" >&2 + exit 1 + esac + '') + ]} + ''} + ''} '' |