summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/flameshot-once
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2020-06-07 19:51:47 +0200
committermakefu <github@syntax-fehler.de>2020-06-07 19:51:47 +0200
commit8dc4c3d153f4f6536815dbb122bf5465ed3a800a (patch)
tree584ff99e146b1b1a40ff1b2ab026de00a984eb0d /krebs/5pkgs/simple/flameshot-once
parent54502928f633568c694cac94dfd4de527c8414bc (diff)
parent8ae780cf2689a0e62718fe0dcc8b80e584f68d23 (diff)
Merge remote-tracking branch 'tv/master'
Diffstat (limited to 'krebs/5pkgs/simple/flameshot-once')
-rw-r--r--krebs/5pkgs/simple/flameshot-once/default.nix1
-rw-r--r--krebs/5pkgs/simple/flameshot-once/profile.nix68
2 files changed, 68 insertions, 1 deletions
diff --git a/krebs/5pkgs/simple/flameshot-once/default.nix b/krebs/5pkgs/simple/flameshot-once/default.nix
index c442a2e96..20c709fb5 100644
--- a/krebs/5pkgs/simple/flameshot-once/default.nix
+++ b/krebs/5pkgs/simple/flameshot-once/default.nix
@@ -16,6 +16,7 @@ in
pkgs.flameshot
pkgs.qt5.qtbase
pkgs.xclip
+ pkgs.xwaitforwindow
]}
${optionalString (config != null) /* sh */ ''
. ${import ./profile.nix { inherit config pkgs; }}
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
+ '')
+ ]}
+ ''}
+ ''}
''