From 880eb5310d3ddf8da4907aadb7ecdf45f2f892d3 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 3 Feb 2023 13:15:23 +0100 Subject: flameshot-once: move to tv --- tv/5pkgs/simple/flameshot-once/default.nix | 28 ++++ tv/5pkgs/simple/flameshot-once/profile.nix | 235 +++++++++++++++++++++++++++++ 2 files changed, 263 insertions(+) create mode 100644 tv/5pkgs/simple/flameshot-once/default.nix create mode 100644 tv/5pkgs/simple/flameshot-once/profile.nix (limited to 'tv/5pkgs/simple') diff --git a/tv/5pkgs/simple/flameshot-once/default.nix b/tv/5pkgs/simple/flameshot-once/default.nix new file mode 100644 index 0000000..0524c2c --- /dev/null +++ b/tv/5pkgs/simple/flameshot-once/default.nix @@ -0,0 +1,28 @@ +{ pkgs, stockholm, ... }@args: +with stockholm.lib; + +let + # config cannot be declared in the input attribute set because that would + # cause callPackage to inject the wrong config. Instead, get it from ... + # via args. + config = args.config or {}; +in + + pkgs.symlinkJoin { + name = "flameshot-once-wrapper"; + paths = [ + (pkgs.writeDashBin "flameshot-once" '' + export PATH=${makeBinPath [ + pkgs.flameshot + pkgs.qt5.qtbase + pkgs.xclip + pkgs.xwaitforwindow + ]} + ${optionalString (config != null) /* sh */ '' + . ${import ./profile.nix { inherit config pkgs; }} + ''} + exec ${pkgs.haskellPackages.flameshot-once}/bin/flameshot-once "$@" + '') + pkgs.haskellPackages.flameshot-once + ]; + } diff --git a/tv/5pkgs/simple/flameshot-once/profile.nix b/tv/5pkgs/simple/flameshot-once/profile.nix new file mode 100644 index 0000000..269f13a --- /dev/null +++ b/tv/5pkgs/simple/flameshot-once/profile.nix @@ -0,0 +1,235 @@ +{ config, pkgs }: +with pkgs.stockholm.lib; +with generators; +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; + CIRCLECOUNT = 19; + }; + + cfg = eval.config; + + eval = evalModules { + modules = singleton { + _file = toString ./profile.nix; + imports = singleton config; + options = { + buttons = mkOption { + apply = map (name: ButtonType.${name}); + default = [ + "PENCIL" + "DRAWER" + "ARROW" + "SELECTION" + "RECTANGLE" + "CIRCLE" + "MARKER" + "SELECTIONINDICATOR" + "MOVESELECTION" + "UNDO" + "SAVE" + "EXIT" + "BLUR" + "CIRCLECOUNT" + ] + ++ optional cfg.imgur.enable "IMAGEUPLOADER" + ; + type = types.listOf (types.enum (attrNames ButtonType)); + }; + copyAndCloseAfterUpload = mkOption { + default = false; + type = types.bool; + }; + disabledTrayIcon = mkOption { + default = true; + type = types.bool; + }; + drawColor = mkOption { + default = "#ff0000"; + type = + types.addCheck types.str (test "#[0-9A-Fa-f]{6}"); + }; + drawThickness = mkOption { + default = 8; + type = types.positive; + }; + filenamePattern = mkOption { + 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._-]*"); + }; + 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; + }; + showDesktopNotification = mkOption { + default = false; + type = types.bool; + }; + showHelp = mkOption { + default = false; + type = types.bool; + }; + showSidePanelButton = mkOption { + default = false; + type = types.bool; + }; + showStartupLaunchMessage = mkOption { + default = false; + type = types.bool; + }; + timeout = mkOption { + default = 200; + description = '' + Maximum time in milliseconds allowed for the flameshot daemon to + react. + ''; + type = types.positive; + }; + }; + }; + }; + + 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" { + "/flameshot/flameshot.ini".text = + toINI {} { + General = { + buttons = ''@Variant(\0\0\0\x7f\0\0\0\v${toQList "int" cfg.buttons})''; + disabledTrayIcon = cfg.disabledTrayIcon; + checkForUpdates = false; + copyAndCloseAfterUpload = cfg.copyAndCloseAfterUpload; + drawColor = cfg.drawColor; + drawThickness = cfg.drawThickness; + filenamePattern = cfg.filenamePattern; + savePath = cfg.savePath; + showDesktopNotification = cfg.showDesktopNotification; + showHelp = cfg.showHelp; + showSidePanelButton = cfg.showSidePanelButton; + showStartupLaunchMessage = cfg.showStartupLaunchMessage; + startupLaunch = false; + }; + Shortcuts = { + TYPE_COPY = "Return"; + }; + }; + }; + +in + + pkgs.writeDash "flameshot.profile" '' + 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 + '') + ]} + ''} + ''} + '' -- cgit v1.2.3 From 1d1ab286f4fda352d3e598a4b2addc3992c02e85 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 4 Feb 2023 21:52:14 +0100 Subject: flameshot-once: reinit with flameshot 12.1.0-pre --- tv/5pkgs/simple/flameshot-once/default.nix | 28 ---- tv/5pkgs/simple/flameshot-once/profile.nix | 235 ----------------------------- 2 files changed, 263 deletions(-) delete mode 100644 tv/5pkgs/simple/flameshot-once/default.nix delete mode 100644 tv/5pkgs/simple/flameshot-once/profile.nix (limited to 'tv/5pkgs/simple') diff --git a/tv/5pkgs/simple/flameshot-once/default.nix b/tv/5pkgs/simple/flameshot-once/default.nix deleted file mode 100644 index 0524c2c..0000000 --- a/tv/5pkgs/simple/flameshot-once/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ pkgs, stockholm, ... }@args: -with stockholm.lib; - -let - # config cannot be declared in the input attribute set because that would - # cause callPackage to inject the wrong config. Instead, get it from ... - # via args. - config = args.config or {}; -in - - pkgs.symlinkJoin { - name = "flameshot-once-wrapper"; - paths = [ - (pkgs.writeDashBin "flameshot-once" '' - export PATH=${makeBinPath [ - pkgs.flameshot - pkgs.qt5.qtbase - pkgs.xclip - pkgs.xwaitforwindow - ]} - ${optionalString (config != null) /* sh */ '' - . ${import ./profile.nix { inherit config pkgs; }} - ''} - exec ${pkgs.haskellPackages.flameshot-once}/bin/flameshot-once "$@" - '') - pkgs.haskellPackages.flameshot-once - ]; - } diff --git a/tv/5pkgs/simple/flameshot-once/profile.nix b/tv/5pkgs/simple/flameshot-once/profile.nix deleted file mode 100644 index 269f13a..0000000 --- a/tv/5pkgs/simple/flameshot-once/profile.nix +++ /dev/null @@ -1,235 +0,0 @@ -{ config, pkgs }: -with pkgs.stockholm.lib; -with generators; -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; - CIRCLECOUNT = 19; - }; - - cfg = eval.config; - - eval = evalModules { - modules = singleton { - _file = toString ./profile.nix; - imports = singleton config; - options = { - buttons = mkOption { - apply = map (name: ButtonType.${name}); - default = [ - "PENCIL" - "DRAWER" - "ARROW" - "SELECTION" - "RECTANGLE" - "CIRCLE" - "MARKER" - "SELECTIONINDICATOR" - "MOVESELECTION" - "UNDO" - "SAVE" - "EXIT" - "BLUR" - "CIRCLECOUNT" - ] - ++ optional cfg.imgur.enable "IMAGEUPLOADER" - ; - type = types.listOf (types.enum (attrNames ButtonType)); - }; - copyAndCloseAfterUpload = mkOption { - default = false; - type = types.bool; - }; - disabledTrayIcon = mkOption { - default = true; - type = types.bool; - }; - drawColor = mkOption { - default = "#ff0000"; - type = - types.addCheck types.str (test "#[0-9A-Fa-f]{6}"); - }; - drawThickness = mkOption { - default = 8; - type = types.positive; - }; - filenamePattern = mkOption { - 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._-]*"); - }; - 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; - }; - showDesktopNotification = mkOption { - default = false; - type = types.bool; - }; - showHelp = mkOption { - default = false; - type = types.bool; - }; - showSidePanelButton = mkOption { - default = false; - type = types.bool; - }; - showStartupLaunchMessage = mkOption { - default = false; - type = types.bool; - }; - timeout = mkOption { - default = 200; - description = '' - Maximum time in milliseconds allowed for the flameshot daemon to - react. - ''; - type = types.positive; - }; - }; - }; - }; - - 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" { - "/flameshot/flameshot.ini".text = - toINI {} { - General = { - buttons = ''@Variant(\0\0\0\x7f\0\0\0\v${toQList "int" cfg.buttons})''; - disabledTrayIcon = cfg.disabledTrayIcon; - checkForUpdates = false; - copyAndCloseAfterUpload = cfg.copyAndCloseAfterUpload; - drawColor = cfg.drawColor; - drawThickness = cfg.drawThickness; - filenamePattern = cfg.filenamePattern; - savePath = cfg.savePath; - showDesktopNotification = cfg.showDesktopNotification; - showHelp = cfg.showHelp; - showSidePanelButton = cfg.showSidePanelButton; - showStartupLaunchMessage = cfg.showStartupLaunchMessage; - startupLaunch = false; - }; - Shortcuts = { - TYPE_COPY = "Return"; - }; - }; - }; - -in - - pkgs.writeDash "flameshot.profile" '' - 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 - '') - ]} - ''} - ''} - '' -- cgit v1.2.3 From 5cfd880000c9af2bb75f55fa83baae4f006facf7 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 5 Feb 2023 02:28:29 +0100 Subject: tv flameshot-once-tv: init --- tv/5pkgs/simple/flameshot-once-tv.nix | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tv/5pkgs/simple/flameshot-once-tv.nix (limited to 'tv/5pkgs/simple') diff --git a/tv/5pkgs/simple/flameshot-once-tv.nix b/tv/5pkgs/simple/flameshot-once-tv.nix new file mode 100644 index 0000000..e3a9f9a --- /dev/null +++ b/tv/5pkgs/simple/flameshot-once-tv.nix @@ -0,0 +1,48 @@ +{ pkgs }: + +pkgs.flameshot-once.override { + name = "flameshot-once-tv"; + config.imgur.enable = true; + config.imgur.createUrl = "http://ni.r/image"; + config.imgur.deleteUrl = "http://ni.r/image/delete/%1"; + config.imgur.xdg-open.browser = "/etc/profiles/per-user/tv/bin/cr"; + config.settings.General = { + autoCloseIdleDaemon = true; + buttons = [ + "TYPE_ARROW" + "TYPE_CIRCLE" + "TYPE_CIRCLECOUNT" + "TYPE_COPY" + "TYPE_DRAWER" + "TYPE_IMAGEUPLOADER" + "TYPE_MARKER" + "TYPE_MOVESELECTION" + "TYPE_PENCIL" + "TYPE_PIXELATE" + "TYPE_RECTANGLE" + "TYPE_SAVE" + "TYPE_SELECTION" + "TYPE_TEXT" + ]; + checkForUpdates = false; + contrastOpacity = 220; + copyPathAfterSave = true; + disabledTrayIcon = true; + drawColor = "#E4002B"; + drawThickness = 8; + filenamePattern = "%FT%T%z_flameshot"; + fontFamily = "iosevka tv 2"; + savePath = "/tmp"; + savePathFixed = true; + showDesktopNotification = false; + showHelp = false; + showSidePanelButton = false; + showStartupLaunchMessage = false; + squareMagnifier = true; + uploadWithoutConfirmation = true; + }; + config.settings.Shortcuts = { + TYPE_COPY = "Return"; + TYPE_TOGGLE_PANEL = "`"; + }; +} -- cgit v1.2.3 From 1f3ff2eeac69bb5a6ca2c3c7b85d24e51197e7eb Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 12 Feb 2023 13:41:09 +0100 Subject: tv q-cal: properly dim all week numbers --- tv/5pkgs/simple/q/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tv/5pkgs/simple') diff --git a/tv/5pkgs/simple/q/default.nix b/tv/5pkgs/simple/q/default.nix index 809e37e..1aea80b 100644 --- a/tv/5pkgs/simple/q/default.nix +++ b/tv/5pkgs/simple/q/default.nix @@ -25,7 +25,7 @@ let fi | ${pkgs.gnused}/bin/sed -r ' # dim week numbers - s/((^ *| )[ 1-5][0-9]( *)?)(([ 1-3][0-9])*)/\1\4/g + s/((^| )[ 1-5][0-9])(( ..| \[7m..\[27m){7})/\1\3/g # dim month and day names s/^ *[A-Z].*/&/ # highlight current date -- cgit v1.2.3