summaryrefslogtreecommitdiffstats
path: root/tv/5pkgs
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2021-01-27 22:57:15 +0100
committermakefu <github@syntax-fehler.de>2021-01-27 22:57:15 +0100
commit144edeee1030d647bcc64083efc5834d1628341d (patch)
tree92f32df8dbc09b1bc36061267967b605628409b7 /tv/5pkgs
parent9c6c20f69e7b76e4231ffeae715d2ee5d453bb4d (diff)
parenta2ca5f2e214be259fdb0f9ea92b79d74e6216a51 (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'tv/5pkgs')
-rw-r--r--tv/5pkgs/haskell/xmonad-tv/src/main.hs8
-rw-r--r--tv/5pkgs/simple/pinentry-urxvt/default.nix56
2 files changed, 63 insertions, 1 deletions
diff --git a/tv/5pkgs/haskell/xmonad-tv/src/main.hs b/tv/5pkgs/haskell/xmonad-tv/src/main.hs
index b8ddd27e8..50b03d81c 100644
--- a/tv/5pkgs/haskell/xmonad-tv/src/main.hs
+++ b/tv/5pkgs/haskell/xmonad-tv/src/main.hs
@@ -8,6 +8,7 @@ import System.Exit (exitFailure)
import Control.Exception
import Control.Monad.Extra (whenJustM)
+import qualified Data.List
import Graphics.X11.ExtraTypes.XF86
import Text.Read (readEither)
import XMonad
@@ -59,6 +60,11 @@ main = getArgs >>= \case
args -> hPutStrLn stderr ("bad arguments: " <> show args) >> exitFailure
+queryPrefix :: Query String -> String -> Query Bool
+queryPrefix query prefix =
+ fmap (Data.List.isPrefixOf prefix) query
+
+
mainNoArgs :: IO ()
mainNoArgs = do
workspaces0 <- getWorkspaces0
@@ -82,7 +88,7 @@ mainNoArgs = do
, manageHook =
composeAll
[ appName =? "fzmenu-urxvt" --> doCenterFloat
- , appName =? "pinentry" --> doCenterFloat
+ , appName `queryPrefix` "pinentry" --> doCenterFloat
, title =? "Upload to Imgur" -->
doRectFloat (W.RationalRect 0 0 (1 % 8) (1 % 8))
, placeHook (smart (1,0))
diff --git a/tv/5pkgs/simple/pinentry-urxvt/default.nix b/tv/5pkgs/simple/pinentry-urxvt/default.nix
new file mode 100644
index 000000000..65b76c077
--- /dev/null
+++ b/tv/5pkgs/simple/pinentry-urxvt/default.nix
@@ -0,0 +1,56 @@
+{ pkgs, ... }@args:
+
+let
+ lib = import <stockholm/lib>;
+
+ # 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 {};
+
+ cfg = eval.config;
+
+ eval = lib.evalModules {
+ modules = lib.singleton {
+ _file = toString ./default.nix;
+ imports = lib.singleton config;
+ options = {
+ appName = lib.mkOption {
+ default = "pinentry-urxvt";
+ type = lib.types.str;
+ };
+ display = lib.mkOption {
+ default = ":0";
+ type = lib.types.str;
+ };
+ };
+ };
+ };
+
+
+in
+
+ pkgs.write "pinentry-urxvt" {
+ "/bin/pinentry".link = pkgs.writeDash "pinentry-urxvt-wrapper" ''
+ set -efu
+ exec 3<&0 4>&1 5>&2
+ export DISPLAY=${lib.shell.escape cfg.display}
+ exec ${pkgs.rxvt_unicode}/bin/urxvt \
+ -name ${lib.shell.escape cfg.appName} \
+ -e ${pkgs.writeDash "pinentry-urxvt-tty" ''
+ set -efu
+ exec 2>&5
+ TTY=$(${pkgs.coreutils}/bin/tty)
+ while read -r line <&3; do
+ case $line in
+ 'OPTION ttyname='*)
+ echo "OPTION ttyname=$TTY"
+ ;;
+ *)
+ echo "$line"
+ esac
+ done | ${pkgs.pinentry.tty}/bin/pinentry-tty "$@" >&4
+ ''} \
+ "$@"
+ '';
+ }