summaryrefslogtreecommitdiffstats
path: root/tv
diff options
context:
space:
mode:
Diffstat (limited to 'tv')
-rw-r--r--tv/2configs/gitrepos.nix6
-rw-r--r--tv/2configs/xserver/default.nix8
-rw-r--r--tv/5pkgs/haskell/flameshot-once.nix20
-rw-r--r--tv/5pkgs/haskell/xmonad-tv/default.nix8
-rw-r--r--tv/5pkgs/haskell/xmonad-tv/src/XMonad/Hooks/EwmhDesktops/Extra.hs117
-rw-r--r--tv/5pkgs/haskell/xmonad-tv/src/main.hs30
-rw-r--r--tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal29
-rw-r--r--tv/5pkgs/override/flameshot/default.nix15
-rw-r--r--tv/5pkgs/override/flameshot/flameshot_imgur_0.10.2.patch35
-rw-r--r--tv/5pkgs/simple/flameshot-once-tv.nix48
-rw-r--r--tv/5pkgs/simple/flameshot-once/default.nix28
-rw-r--r--tv/5pkgs/simple/flameshot-once/profile.nix235
12 files changed, 193 insertions, 386 deletions
diff --git a/tv/2configs/gitrepos.nix b/tv/2configs/gitrepos.nix
index d8e7755fe..eb87f26d1 100644
--- a/tv/2configs/gitrepos.nix
+++ b/tv/2configs/gitrepos.nix
@@ -74,9 +74,6 @@ with import ./lib;
disko = {
cgit.desc = "declarative partitioning and formatting tool";
};
- flameshot-once = {
- cgit.desc = "flameshot runner that automatically starts/stops the daemon";
- };
fswm = {
cgit.desc = "simple full screen window manager";
};
@@ -139,6 +136,9 @@ with import ./lib;
cgserver = {};
crude-mail-setup = {};
dot-xmonad = {};
+ flameshot-once = {
+ cgit.desc = "flameshot runner that automatically starts/stops the daemon";
+ };
hirc = {};
hstool = {
cgit.desc = "Haskell Development Environment ^_^";
diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix
index f534b557e..f10ccb10e 100644
--- a/tv/2configs/xserver/default.nix
+++ b/tv/2configs/xserver/default.nix
@@ -120,13 +120,7 @@ in {
};
path = [
config.tv.slock.package
- (pkgs.flameshot-once.override {
- 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.timeout = 200;
- })
+ pkgs.flameshot-once-tv
pkgs.pulseaudio.out
pkgs.rxvt_unicode
pkgs.xcalib
diff --git a/tv/5pkgs/haskell/flameshot-once.nix b/tv/5pkgs/haskell/flameshot-once.nix
deleted file mode 100644
index c8007ce9e..000000000
--- a/tv/5pkgs/haskell/flameshot-once.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-{ mkDerivation, async, base, blessings, bytestring, dbus, fetchgit
-, iso8601-time, lib, process, random, text, time, unagi-chan, unix
-}:
-mkDerivation {
- pname = "flameshot-once";
- version = "1.4.0";
- src = fetchgit {
- url = "https://cgit.krebsco.de/flameshot-once";
- sha256 = "13szgsiwn29aixm5xvs1m7128y5km5xss0ry5ii5y068rc2vysw8";
- rev = "4475893c2081b3d9db4b7a54d0ce38d0914a17bf";
- fetchSubmodules = true;
- };
- isLibrary = false;
- isExecutable = true;
- executableHaskellDepends = [
- async base blessings bytestring dbus iso8601-time process random
- text time unagi-chan unix
- ];
- license = lib.licenses.mit;
-}
diff --git a/tv/5pkgs/haskell/xmonad-tv/default.nix b/tv/5pkgs/haskell/xmonad-tv/default.nix
index be3eca982..f42f97c2a 100644
--- a/tv/5pkgs/haskell/xmonad-tv/default.nix
+++ b/tv/5pkgs/haskell/xmonad-tv/default.nix
@@ -1,6 +1,5 @@
{ mkDerivation, aeson, base, bytestring, containers, directory
-, extra, filepath, lib, systemd, template-haskell, th-env
-, transformers, unix, X11, xmonad, xmonad-contrib
+, extra, filepath, lib, pager, unix, X11, xmonad, xmonad-contrib
}:
mkDerivation {
pname = "xmonad-tv";
@@ -9,8 +8,9 @@ mkDerivation {
isLibrary = false;
isExecutable = true;
executableHaskellDepends = [
- aeson base bytestring containers directory extra filepath systemd
- template-haskell th-env transformers unix X11 xmonad xmonad-contrib
+ aeson base bytestring containers directory extra filepath pager
+ unix X11 xmonad xmonad-contrib
];
license = lib.licenses.mit;
+ mainProgram = "xmonad";
}
diff --git a/tv/5pkgs/haskell/xmonad-tv/src/XMonad/Hooks/EwmhDesktops/Extra.hs b/tv/5pkgs/haskell/xmonad-tv/src/XMonad/Hooks/EwmhDesktops/Extra.hs
new file mode 100644
index 000000000..bf8431446
--- /dev/null
+++ b/tv/5pkgs/haskell/xmonad-tv/src/XMonad/Hooks/EwmhDesktops/Extra.hs
@@ -0,0 +1,117 @@
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE MultiWayIf #-}
+{-# LANGUAGE NamedFieldPuns #-}
+
+module XMonad.Hooks.EwmhDesktops.Extra where
+
+import Control.Monad (when)
+import Data.Maybe (fromMaybe)
+import Data.Monoid (All)
+import Data.Tuple.Extra (both)
+import Graphics.X11.EWMH (getDesktopNames, setDesktopNames)
+import Graphics.X11.EWMH.Atom (_NET_DESKTOP_NAMES)
+import Graphics.X11.Xlib.Display.Extra (withDefaultDisplay)
+import XMonad hiding (workspaces)
+import XMonad.Actions.DynamicWorkspaces (addHiddenWorkspace, removeEmptyWorkspaceByTag)
+import XMonad.StackSet (mapWorkspace, tag, workspaces)
+import XMonad.Util.WorkspaceCompare (getSortByIndex)
+import qualified Data.Map.Strict as Map
+import qualified Data.Set as Set
+import qualified XMonad
+
+
+ewmhExtra :: XConfig a -> IO (XConfig a)
+ewmhExtra c = do
+ -- XMonad.Hooks.EwmhDesktops.setDesktopViewport uses _NET_DESKTOP_VIEWPORT
+ -- only if it exists. This seems to be a harmless issue, but by creating
+ -- the atom here, we suppress the error message:
+ --
+ -- xmonad: X11 error: BadAtom (invalid Atom parameter),
+ -- request code=18, error code=5
+ --
+ _ <-
+ withDefaultDisplay $ \dpy -> internAtom dpy "_NET_DESKTOP_VIEWPORT" False
+
+ initialWorkspaces <-
+ Data.Maybe.fromMaybe (XMonad.workspaces def)
+ <$> withDefaultDisplay getDesktopNames
+
+ return
+ c { handleEventHook = ewmhDesktopsExtraEventHook <> handleEventHook c
+ , rootMask = rootMask c .|. propertyChangeMask
+ , XMonad.workspaces = initialWorkspaces
+ }
+
+ewmhDesktopsExtraEventHook :: Event -> X All
+ewmhDesktopsExtraEventHook = \case
+ PropertyEvent{ev_window, ev_atom} -> do
+ r <- asks theRoot
+ when (ev_window == r && ev_atom == _NET_DESKTOP_NAMES) $
+ withDisplay $ \dpy -> do
+ sort <- getSortByIndex
+
+ oldNames <- gets $ map tag . sort . workspaces . windowset
+ newNames <- fromMaybe oldNames <$> io (getDesktopNames dpy)
+
+ let
+ (renamesFrom, renamesTo) = both Set.fromList $ unzip renames
+
+ renames = go oldNames newNames where
+ go old@(headOld : tailOld) new@(headNew : tailNew) = do
+ let
+ deleteOld = Set.member headOld deleteNameSet
+ createNew = Set.member headNew createNameSet
+
+ if
+ | headOld == headNew ->
+ -- assert (not deleteOld && not createNew)
+ go tailOld tailNew
+
+ | deleteOld && createNew ->
+ (headOld, headNew) :
+ go tailOld tailNew
+
+ | deleteOld ->
+ go tailOld new
+
+ | createNew ->
+ go old tailNew
+
+ | otherwise ->
+ -- assert (headOld == headNew)
+ go tailOld tailNew
+
+ go _ _ = []
+
+ oldNameSet = Set.fromList oldNames
+ newNameSet = Set.fromList newNames
+ deleteNameSet = Set.difference oldNameSet newNameSet
+ createNameSet = Set.difference newNameSet oldNameSet
+
+ deleteNames = Set.toAscList $
+ Set.difference deleteNameSet renamesFrom
+ createNames = Set.toAscList $
+ Set.difference createNameSet renamesTo
+
+ mapM_ addHiddenWorkspace createNames
+ mapM_ removeEmptyWorkspaceByTag deleteNames
+ when (not (null renames)) $ do
+ let
+ renameMap = Map.fromList renames
+ rename w =
+ case Map.lookup (tag w) renameMap of
+ Just newName -> w { tag = newName }
+ Nothing -> w
+
+ modifyWindowSet $ mapWorkspace rename
+
+ names <- gets $ map tag . sort . workspaces . windowset
+
+ when (names /= newNames) $ do
+ trace $ "setDesktopNames " <> show names
+ io (setDesktopNames names dpy)
+
+ mempty
+
+ _ ->
+ mempty
diff --git a/tv/5pkgs/haskell/xmonad-tv/src/main.hs b/tv/5pkgs/haskell/xmonad-tv/src/main.hs
index 118f2da46..7256963a5 100644
--- a/tv/5pkgs/haskell/xmonad-tv/src/main.hs
+++ b/tv/5pkgs/haskell/xmonad-tv/src/main.hs
@@ -5,16 +5,15 @@ module Main (main) where
import System.Exit (exitFailure)
import XMonad.Hooks.EwmhDesktops (ewmh)
+import XMonad.Hooks.EwmhDesktops.Extra (ewmhExtra)
import XMonad.Hooks.RefocusLast (refocusLastLayoutHook, toggleFocus)
-import Control.Exception
import Control.Monad.Extra (whenJustM)
import qualified Data.Aeson
import qualified Data.ByteString.Char8
import qualified Data.List
import qualified Data.Maybe
import Graphics.X11.ExtraTypes.XF86
-import Text.Read (readEither)
import XMonad
import XMonad.Extra (isFloatingX)
import System.IO (hPutStrLn, stderr)
@@ -76,11 +75,10 @@ mainNoArgs = do
myTermFont <- getEnv "XMONAD_TERM_FONT"
myTermFontWidth <- readEnv "XMONAD_TERM_FONT_WIDTH" :: IO Dimension
myTermPadding <- readEnv "XMONAD_TERM_PADDING" :: IO Dimension
- workspaces0 <- getWorkspaces0
handleShutdownEvent <- newShutdownEventHandler
- let
- config =
- ewmh
+ config <-
+ ewmhExtra
+ $ ewmh
$ withUrgencyHookC
BorderUrgencyHook
{ urgencyBorderColor = "#ff0000"
@@ -93,7 +91,6 @@ mainNoArgs = do
{ terminal = {-pkg:alacritty-tv-}"alacritty"
, modMask = mod4Mask
, keys = myKeys myTermFont
- , workspaces = workspaces0
, layoutHook =
refocusLastLayoutHook $
gaps (zip [U,R,D,L] myScreenGaps) $
@@ -125,23 +122,6 @@ mainNoArgs = do
launch config directories
-getWorkspaces0 :: IO [String]
-getWorkspaces0 =
- try (getEnv "XMONAD_WORKSPACES0_FILE") >>= \case
- Left e -> warn (displaySomeException e)
- Right p -> try (readFile p) >>= \case
- Left e -> warn (displaySomeException e)
- Right x -> case readEither x of
- Left e -> warn e
- Right y -> return y
- where
- warn msg = hPutStrLn stderr ("getWorkspaces0: " ++ msg) >> return []
-
-
-displaySomeException :: SomeException -> String
-displaySomeException = displayException
-
-
forkFile :: FilePath -> [String] -> Maybe [(String, String)] -> X ()
forkFile path args env =
xfork (executeFile path True args env) >> return ()
@@ -206,7 +186,7 @@ myKeys font conf = Map.fromList $
, ((_4, xK_Prior), forkFile {-pkg-}"xcalib" ["-invert", "-alter"] Nothing)
- , ((0, xK_Print), forkFile {-pkg-}"flameshot" [] Nothing)
+ , ((0, xK_Print), forkFile {-pkg:flameshot-once-tv-}"flameshot-once" [] Nothing)
, ((_C, xF86XK_Forward), forkFile {-pkg:xdpytools-}"xdpychvt" ["next"] Nothing)
, ((_C, xF86XK_Back), forkFile {-pkg:xdpytools-}"xdpychvt" ["prev"] Nothing)
diff --git a/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal b/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal
index 62faf2f00..f211627bf 100644
--- a/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal
+++ b/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal
@@ -9,20 +9,21 @@ cabal-version: >=1.10
executable xmonad
main-is: main.hs
build-depends:
- aeson,
- base,
- bytestring,
- containers,
- directory,
- extra,
- filepath,
- template-haskell,
- th-env,
- unix,
- X11,
- xmonad,
- xmonad-contrib
+ base
+ , X11
+ , aeson
+ , bytestring
+ , containers
+ , directory
+ , extra
+ , filepath
+ , pager
+ , unix
+ , xmonad
+ , xmonad-contrib
other-modules:
Shutdown
+ XMonad.Extra
+ XMonad.Hooks.EwmhDesktops.Extra
default-language: Haskell2010
- ghc-options: -O2 -Wall -threaded
+ ghc-options: -O2 -Wall
diff --git a/tv/5pkgs/override/flameshot/default.nix b/tv/5pkgs/override/flameshot/default.nix
deleted file mode 100644
index 10154cc44..000000000
--- a/tv/5pkgs/override/flameshot/default.nix
+++ /dev/null
@@ -1,15 +0,0 @@
-self: super:
-
-super.flameshot.overrideAttrs (old: rec {
- name = "flameshot-${version}";
- version = "0.10.2";
- src = self.fetchFromGitHub {
- owner = "flameshot-org";
- repo = "flameshot";
- rev = "v${version}";
- sha256 = "sha256-rZUiaS32C77tFJmEkw/9MGbVTVscb6LOCyWaWO5FyR4=";
- };
- patches = old.patches or [] ++ [
- ./flameshot_imgur_0.10.2.patch
- ];
-})
diff --git a/tv/5pkgs/override/flameshot/flameshot_imgur_0.10.2.patch b/tv/5pkgs/override/flameshot/flameshot_imgur_0.10.2.patch
deleted file mode 100644
index c4c0bf38a..000000000
--- a/tv/5pkgs/override/flameshot/flameshot_imgur_0.10.2.patch
+++ /dev/null
@@ -1,35 +0,0 @@
---- a/src/tools/imgur/imguruploader.cpp
-+++ b/src/tools/imgur/imguruploader.cpp
-@@ -31,6 +31,7 @@
- #include <QTimer>
- #include <QUrlQuery>
- #include <QVBoxLayout>
-+#include <stdlib.h>
-
- ImgurUploader::ImgurUploader(const QPixmap& capture, QWidget* parent)
- : QWidget(parent)
-@@ -79,8 +80,11 @@ void ImgurUploader::handleReply(QNetworkReply* reply)
- m_imageURL.setUrl(data[QStringLiteral("link")].toString());
-
- auto deleteToken = data[QStringLiteral("deletehash")].toString();
-+ char *deleteImageURLPattern = secure_getenv("IMGUR_DELETE_URL");
-+ if (deleteImageURLPattern == NULL)
-+ deleteImageURLPattern = "https://imgur.com/delete/%1";
- m_deleteImageURL.setUrl(
-- QStringLiteral("https://imgur.com/delete/%1").arg(deleteToken));
-+ QString::fromUtf8(deleteImageURLPattern).arg(deleteToken));
-
- // save history
- QString imageName = m_imageURL.toString();
-@@ -133,7 +137,10 @@ void ImgurUploader::upload()
- QString description = FileNameHandler().parsedPattern();
- urlQuery.addQueryItem(QStringLiteral("description"), description);
-
-- QUrl url(QStringLiteral("https://api.imgur.com/3/image"));
-+ char *createImageURLPattern = secure_getenv("IMGUR_CREATE_URL");
-+ if (createImageURLPattern == NULL)
-+ createImageURLPattern = "https://api.imgur.com/3/image";
-+ QUrl url(QString::fromUtf8(createImageURLPattern));
- url.setQuery(urlQuery);
- QNetworkRequest request(url);
- request.setHeader(QNetworkRequest::ContentTypeHeader,
diff --git a/tv/5pkgs/simple/flameshot-once-tv.nix b/tv/5pkgs/simple/flameshot-once-tv.nix
new file mode 100644
index 000000000..e3a9f9a4f
--- /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 = "`";
+ };
+}
diff --git a/tv/5pkgs/simple/flameshot-once/default.nix b/tv/5pkgs/simple/flameshot-once/default.nix
deleted file mode 100644
index 0524c2cfa..000000000
--- 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 269f13a66..000000000
--- 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
- '')
- ]}
- ''}
- ''}
- ''