diff options
author | lassulus <lassulus@lassul.us> | 2021-03-07 23:22:35 +0100 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2021-03-07 23:22:35 +0100 |
commit | b81eb46c7d6439af7b7cedff9d4f81714f235d15 (patch) | |
tree | e62bdd6e86008f8b888a87d8337750e33a46f033 | |
parent | 6fee4ac9fef8200624e62f5e339abfae860ff497 (diff) | |
parent | a9b82ce4124cb3a3f2e6ee8b087c0d8461bad386 (diff) |
Merge remote-tracking branch 'ni/master'
-rw-r--r-- | krebs/5pkgs/haskell/X11-aeson.nix | 13 | ||||
-rw-r--r-- | krebs/5pkgs/haskell/hack.nix | 22 | ||||
-rw-r--r-- | krebs/5pkgs/haskell/xmonad-aeson.nix | 13 | ||||
-rw-r--r-- | lib/default.nix | 4 | ||||
-rw-r--r-- | tv/2configs/gitrepos.nix | 6 | ||||
-rw-r--r-- | tv/2configs/hw/w110er.nix | 2 | ||||
-rw-r--r-- | tv/5pkgs/haskell/xmonad-tv/src/Paths.hs | 3 | ||||
-rw-r--r-- | tv/5pkgs/haskell/xmonad-tv/src/XMonad/Extra.hs | 14 | ||||
-rw-r--r-- | tv/5pkgs/haskell/xmonad-tv/src/main.hs | 28 | ||||
-rw-r--r-- | tv/5pkgs/simple/mpvterm/default.nix | 8 | ||||
-rw-r--r-- | tv/5pkgs/simple/mpvterm/mpvterm.patch | 146 |
11 files changed, 252 insertions, 7 deletions
diff --git a/krebs/5pkgs/haskell/X11-aeson.nix b/krebs/5pkgs/haskell/X11-aeson.nix new file mode 100644 index 000000000..7db6c28a8 --- /dev/null +++ b/krebs/5pkgs/haskell/X11-aeson.nix @@ -0,0 +1,13 @@ +{ mkDerivation, aeson, base, fetchgit, stdenv, X11 }: +mkDerivation { + pname = "X11-aeson"; + version = "1.0.0"; + src = fetchgit { + url = "https://cgit.krebsco.de/X11-aeson"; + sha256 = "0y9nvssqpvqgl46g7nz9738l8jmpa7an8r3am3qaqcvmvzgwxh0d"; + rev = "c0a70a62513baf2b437db4ebe3e5a32e3cfa5905"; + fetchSubmodules = true; + }; + libraryHaskellDepends = [ aeson base X11 ]; + license = stdenv.lib.licenses.mit; +} diff --git a/krebs/5pkgs/haskell/hack.nix b/krebs/5pkgs/haskell/hack.nix new file mode 100644 index 000000000..4e157107e --- /dev/null +++ b/krebs/5pkgs/haskell/hack.nix @@ -0,0 +1,22 @@ +{ mkDerivation, base, blessings, containers, data-default, fetchgit +, lens, mtl, old-locale, process, scanner, stdenv, time, unix +, zippers +}: +mkDerivation { + pname = "hack"; + version = "1.0.0"; + src = fetchgit { + url = "https://cgit.krebsco.de/hack"; + sha256 = "0hi6frpnxbg3h6s7gd48ri57jc226qycy4rnhmpzpq195xf8y3pf"; + rev = "cb004b2e5f0fce6cea8d54e60558a1c1904dbe39"; + fetchSubmodules = true; + }; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ base ]; + executableHaskellDepends = [ + base blessings containers data-default lens mtl old-locale process + scanner time unix zippers + ]; + license = stdenv.lib.licenses.mit; +} diff --git a/krebs/5pkgs/haskell/xmonad-aeson.nix b/krebs/5pkgs/haskell/xmonad-aeson.nix new file mode 100644 index 000000000..3fccab469 --- /dev/null +++ b/krebs/5pkgs/haskell/xmonad-aeson.nix @@ -0,0 +1,13 @@ +{ mkDerivation, aeson, base, fetchgit, stdenv, X11-aeson, xmonad }: +mkDerivation { + pname = "xmonad-aeson"; + version = "1.0.0"; + src = fetchgit { + url = "https://cgit.krebsco.de/xmonad-aeson"; + sha256 = "0l1gna6p1498vzm6kj0ywj0i7775mz5n7k9nymwggvfb1pyxv3h9"; + rev = "a95f652b150f17db3f2439214a6346335d6d8d89"; + fetchSubmodules = true; + }; + libraryHaskellDepends = [ aeson base X11-aeson xmonad ]; + license = stdenv.lib.licenses.mit; +} diff --git a/lib/default.nix b/lib/default.nix index 2efeec078..4190f8f5f 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -15,6 +15,10 @@ let uri = import ./uri.nix { inherit lib; }; xml = import ./xml.nix { inherit lib; }; + # compose a list of functions to be applied from left to right, i.e. + # compose :: [ (xm -> xn) ... (x1 -> x2) (x0 -> x1) ] -> x0 -> xn + compose = foldl' (f: g: x: f (g x)) id; + eq = x: y: x == y; ne = x: y: x != y; mod = x: y: x - y * (x / y); diff --git a/tv/2configs/gitrepos.nix b/tv/2configs/gitrepos.nix index 5b6a70b27..2e73640ff 100644 --- a/tv/2configs/gitrepos.nix +++ b/tv/2configs/gitrepos.nix @@ -96,6 +96,8 @@ let { nix-writers = { cgit.desc = "collection of package builders"; }; + pager = { + }; populate = { cgit.desc = "source code installer"; }; @@ -113,7 +115,9 @@ let { ni = { }; } // mapAttrs (_: recursiveUpdate { cgit.section = "3. Haskell libraries"; }) { + X11-aeson = {}; blessings = {}; + hack = {}; hc = {}; mime = {}; quipper = {}; @@ -121,7 +125,9 @@ let { wai-middleware-time = {}; web-routes-wai-custom = {}; xintmap = {}; + xmonad-aeson = {}; xmonad-stockholm = {}; + xmonad-web = {}; } // mapAttrs (_: recursiveUpdate { cgit.section = "4. museum"; }) { cac-api = { cgit.desc = "CloudAtCost API command line interface"; diff --git a/tv/2configs/hw/w110er.nix b/tv/2configs/hw/w110er.nix index 693cef5ac..818d1aca6 100644 --- a/tv/2configs/hw/w110er.nix +++ b/tv/2configs/hw/w110er.nix @@ -28,6 +28,8 @@ with import <stockholm/lib>; boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; + hardware.enableRedistributableFirmware = true; + hardware.opengl.driSupport32Bit = true; hardware.opengl.extraPackages = [ pkgs.vaapiIntel ]; diff --git a/tv/5pkgs/haskell/xmonad-tv/src/Paths.hs b/tv/5pkgs/haskell/xmonad-tv/src/Paths.hs index b2ad01ae7..2569b60c3 100644 --- a/tv/5pkgs/haskell/xmonad-tv/src/Paths.hs +++ b/tv/5pkgs/haskell/xmonad-tv/src/Paths.hs @@ -32,3 +32,6 @@ xcalib = findExecutable "xcalib" xdpychvt :: FilePath xdpychvt = findExecutable "xdpychvt" + +xterm :: FilePath +xterm = findExecutable "xterm" diff --git a/tv/5pkgs/haskell/xmonad-tv/src/XMonad/Extra.hs b/tv/5pkgs/haskell/xmonad-tv/src/XMonad/Extra.hs new file mode 100644 index 000000000..74222712d --- /dev/null +++ b/tv/5pkgs/haskell/xmonad-tv/src/XMonad/Extra.hs @@ -0,0 +1,14 @@ +module XMonad.Extra where + +import XMonad +import qualified Data.Map as Map +import qualified XMonad.StackSet as W + + +isFloating :: Window -> WindowSet -> Bool +isFloating w = + Map.member w . W.floating + +isFloatingX :: Window -> X Bool +isFloatingX w = + isFloating w <$> gets windowset diff --git a/tv/5pkgs/haskell/xmonad-tv/src/main.hs b/tv/5pkgs/haskell/xmonad-tv/src/main.hs index e5a4473fe..48127a594 100644 --- a/tv/5pkgs/haskell/xmonad-tv/src/main.hs +++ b/tv/5pkgs/haskell/xmonad-tv/src/main.hs @@ -7,11 +7,12 @@ module Main (main) where import System.Exit (exitFailure) import Control.Exception -import Control.Monad.Extra (whenJustM) +import Control.Monad.Extra (ifM, whenJustM) import qualified Data.List import Graphics.X11.ExtraTypes.XF86 import Text.Read (readEither) import XMonad +import XMonad.Extra (isFloatingX) import System.IO (hPutStrLn, stderr) import System.Environment (getArgs, getEnv, getEnvironment, lookupEnv) import System.Posix.Process (executeFile) @@ -60,9 +61,8 @@ 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 +(=??) :: Query a -> (a -> Bool) -> Query Bool +(=??) x p = fmap p x mainNoArgs :: IO () @@ -88,7 +88,8 @@ mainNoArgs = do , manageHook = composeAll [ appName =? "fzmenu-urxvt" --> doCenterFloat - , appName `queryPrefix` "pinentry" --> doCenterFloat + , appName =?? Data.List.isPrefixOf "pinentry" --> doCenterFloat + , appName =?? Data.List.isInfixOf "Float" --> doCenterFloat , title =? "Upload to Imgur" --> doRectFloat (W.RationalRect 0 0 (1 % 8) (1 % 8)) , placeHook (smart (1,0)) @@ -154,8 +155,8 @@ myKeys conf = Map.fromList $ , ((_S , xK_Menu ), gets windowset >>= allWorkspaceNames >>= pager pagerConfig (windows . W.shift) ) , ((_C , xK_Menu ), toggleWS) - , ((_4 , xK_space ), sendMessage NextLayout) - , ((_4M , xK_space ), resetLayout) + , ((_4 , xK_space ), withFocused $ \w -> ifM (isFloatingX w) xdeny $ sendMessage NextLayout) + , ((_4M , xK_space ), withFocused $ \w -> ifM (isFloatingX w) xdeny $ resetLayout) , ((_4 , xK_m ), windows W.focusMaster) , ((_4 , xK_j ), windows W.focusDown) @@ -218,6 +219,19 @@ myKeys conf = Map.fromList $ def { XMonad.Prompt.font = myFont } +xdeny :: X () +xdeny = + forkFile + Paths.xterm + [ "-fn", myFont + , "-geometry", "300x100" + , "-name", "AlertFloat" + , "-bg", "#E4002B" + , "-e", "sleep", "0.05" + ] + Nothing + + pagerConfig :: PagerConfig pagerConfig = def { pc_font = myFont diff --git a/tv/5pkgs/simple/mpvterm/default.nix b/tv/5pkgs/simple/mpvterm/default.nix new file mode 100644 index 000000000..66ad08a78 --- /dev/null +++ b/tv/5pkgs/simple/mpvterm/default.nix @@ -0,0 +1,8 @@ +{ pkgs }: + +pkgs.mpv-unwrapped.overrideAttrs (old: rec { + pname = "mpvterm"; + patches = old.patches or [] ++ [ + ./mpvterm.patch + ]; +}) diff --git a/tv/5pkgs/simple/mpvterm/mpvterm.patch b/tv/5pkgs/simple/mpvterm/mpvterm.patch new file mode 100644 index 000000000..12636880d --- /dev/null +++ b/tv/5pkgs/simple/mpvterm/mpvterm.patch @@ -0,0 +1,146 @@ +commit 5ded4dac370ce5d8d727c5d3891448f942edbfdf +Author: tv <tv@krebsco.de> +Date: Sat Feb 27 22:54:55 2021 +0100 + + x11: add input forwarding support + +diff --git a/video/out/x11_common.c b/video/out/x11_common.c +index ac551fae8e..2e95451d7f 100644 +--- a/video/out/x11_common.c ++++ b/video/out/x11_common.c +@@ -25,6 +25,10 @@ + #include <string.h> + #include <assert.h> + ++#include <stdarg.h> ++#include <sys/socket.h> ++#include <sys/un.h> ++ + #include <X11/Xmd.h> + #include <X11/Xlib.h> + #include <X11/Xutil.h> +@@ -1097,6 +1101,73 @@ static void release_all_keys(struct vo *vo) + x11->win_drag_button1_down = false; + } + ++ ++#define FORWARD_START 1 ++#define FORWARD_READY 2 ++#define FORWARD_ERROR 3 ++static int forward_state = FORWARD_START; ++static int forward_fd, forward_len; ++static struct sockaddr_un forward_un; ++static char forward_buf[BUFSIZ]; ++ ++static void forward_start(void) { ++ const char *socket_path = getenv("FORWARD_SOCKET"); ++ if (socket_path == NULL) { ++ fprintf(stderr, "forward_start: environment variable FORWARD_SOCKET not set\n"); ++ forward_state = FORWARD_ERROR; ++ return; ++ } ++ ++ if ((forward_fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) { ++ perror("socket"); ++ } else { ++ memset(&forward_un, 0, sizeof(forward_un)); ++ forward_un.sun_family = AF_UNIX; ++ strcpy(forward_un.sun_path, socket_path); ++ forward_len = offsetof(struct sockaddr_un, sun_path) + strlen(socket_path); ++ forward_state = FORWARD_READY; ++ } ++} ++static void forward_send(const char *fmt, ...) { ++ if (forward_state != FORWARD_READY) return; ++ ++ va_list argp; ++ va_start(argp, fmt); ++ int n1 = vsnprintf(forward_buf, BUFSIZ, fmt, argp); ++ if (n1 < BUFSIZ + 1) { ++ forward_buf[n1++] = '\n'; ++ forward_buf[n1] = '\0'; ++ int n2 = sendto(forward_fd, forward_buf, n1, 0, (struct sockaddr *)&forward_un, forward_len); ++ if (n2 < 0) { ++ perror("sendto"); ++ } ++ } ++} ++static const char *forward_keyname(KeySym keySym) { ++ const char *name; ++ if (keySym == NoSymbol) { ++ name = "NoSymbol"; ++ } else if (!(name = XKeysymToString(keySym))) { ++ name = "NoName"; ++ } ++ return name; ++} ++static void forward_keydown(KeySym keySym) { ++ forward_send("xdotool keydown %s", forward_keyname(keySym)); ++} ++static void forward_keyup(KeySym keySym) { ++ forward_send("xdotool keyup %s", forward_keyname(keySym)); ++} ++static void forward_mousedown(int button) { ++ forward_send("xdotool mousedown %d", button); ++} ++static void forward_mouseup(int button) { ++ forward_send("xdotool mouseup %d", button); ++} ++static void forward_mousemove(int x, int y) { ++ forward_send("xdotool mousemove %d %d", x, y); ++} ++ + void vo_x11_check_events(struct vo *vo) + { + struct vo_x11_state *x11 = vo->x11; +@@ -1105,6 +1176,10 @@ void vo_x11_check_events(struct vo *vo) + + xscreensaver_heartbeat(vo->x11); + ++ if (forward_state == FORWARD_START) { ++ forward_start(); ++ } ++ + while (XPending(display)) { + XNextEvent(display, &Event); + MP_TRACE(x11, "XEvent: %d\n", Event.type); +@@ -1146,6 +1221,7 @@ void vo_x11_check_events(struct vo *vo) + if (mpkey) + mp_input_put_key(x11->input_ctx, mpkey | modifiers); + } ++ forward_keydown(XLookupKeysym(&Event.xkey, 0)); + break; + } + case FocusIn: +@@ -1161,6 +1237,7 @@ void vo_x11_check_events(struct vo *vo) + break; + case KeyRelease: + release_all_keys(vo); ++ forward_keyup(XLookupKeysym(&Event.xkey, 0)); + break; + case MotionNotify: + if (x11->win_drag_button1_down && !x11->fs && +@@ -1182,6 +1259,7 @@ void vo_x11_check_events(struct vo *vo) + Event.xmotion.y); + } + x11->win_drag_button1_down = false; ++ forward_mousemove(Event.xmotion.x, Event.xmotion.y); + break; + case LeaveNotify: + if (Event.xcrossing.mode != NotifyNormal) +@@ -1204,6 +1282,7 @@ void vo_x11_check_events(struct vo *vo) + get_mods(Event.xbutton.state) | MP_KEY_STATE_DOWN); + long msg[4] = {XEMBED_REQUEST_FOCUS}; + vo_x11_xembed_send_message(x11, msg); ++ forward_mousedown(Event.xbutton.button); + break; + case ButtonRelease: + if (Event.xbutton.button - 1 >= MP_KEY_MOUSE_BTN_COUNT) +@@ -1213,6 +1292,7 @@ void vo_x11_check_events(struct vo *vo) + mp_input_put_key(x11->input_ctx, + (MP_MBTN_BASE + Event.xbutton.button - 1) | + get_mods(Event.xbutton.state) | MP_KEY_STATE_UP); ++ forward_mouseup(Event.xbutton.button); + break; + case MapNotify: + x11->window_hidden = false; |