]> Skullheadx's Git Forge - nixos.git/commitdiff
move sxhkd to x11 config, update surf search
authorSkullheadx <admonty1@protonmail.com>
Mon, 4 May 2026 22:57:17 +0000 (18:57 -0400)
committerSkullheadx <admonty1@protonmail.com>
Mon, 4 May 2026 22:57:17 +0000 (18:57 -0400)
configuration.nix
dotfiles/surf/surf.sh
flake.lock
hjem.nix
overlays.nix
scripts/surf_search.nix [new file with mode: 0644]
todo
x11.nix

index 5efc8ec257515b8bcaab0c85d0cba6393968ecf1..5e130fd95a491420ec1974e4f8b1e8623b3757f8 100644 (file)
@@ -60,6 +60,7 @@
     slstatus
     scrolling-title
     surf
+    surf_search
     terminus_font
     terminus_font_ttf
     yt-dlp
index bdc040d58b51055ad9787a290aecebd67d9f86cb..58568e435fa05cc742dc5f951cf5bf4d600983b6 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# v. 2.0 - upgrade based on surf 4.0
+# v. 2.0 - upgrade ba@gnused@/bin/sed on surf 4.0
 # Creative Commons License.  Peter John Hartman (http://individual.utoronto.ca/peterjh)
 # Much thanks to nibble and pancake who have a different surf.sh script available which
 # doesn't do the history bit.
@@ -33,82 +33,85 @@ mkdir -p "$HOME/.local/share/surf"
 
 
 pid=$1
-fid=$2
+fid=$2
 xid=$3
 
 
-dmenu="@dmenu@/bin/dmenu -nb $normbgcolor -nf $normfgcolor \
-          -sb $selbgcolor -sf $selfgcolor"
-xprop="@xprop@/bin/xprop"
-sed="@gnused@/bin/sed"
-tac="@coreutils@/bin/tac"
+dmenu_cmd () {
 
-s_get_prop() { # xprop
-       xprop -id $xid $1 | cut -d '"' -f 2
+    @dmenu@/bin/dmenu -nb "$normbgcolor" -nf "$normfgcolor" \
+           -sb "$selbgcolor" -sf "$selfgcolor" "$@"
 }
-s_set_prop() { # xprop value
-       [ -n "$2" ] && xprop -id $xid -f $1 8u -set $1 "$2"
+
+s_get_prop() { # "@xprop@/bin/xprop
+       @xprop@/bin/xprop -id "$xid" "$1" | cut -d '\"' -f 2
+}
+s_set_prop() { # @xprop@/bin/xprop value
+       [ -n """$2""" ] && @xprop@/bin/xprop -id """$xid""" -f """$1""" 8u -set """$1""" """$2"""
 }
 s_write_f() { # file value
-       [ -n "$2" ] && (sed -i "\|$2|d" $1; echo "$2" >> $1)
-       #grep "$uri" $bmarks >/dev/null 2>&1 || echo "$uri" >> $bmarks
+       [ -n "$2" ] && (@gnused@/bin/sed -i "\|$2|d" "$1"; echo "$2" >> "$1")
 }
 s_set_write_proper_uri() { # uri
-       # TODO: (xprop -spy _SURF_URI ... | while read name __ value; do echo $value; done works quite nice for eventloops)
-       # input is whatever the use inputed, so don't store that!
-       # first, clear the name field because surf doesn't sometimes
-       #s_set_prop WM_ICON_NAME ""
-       # set the uri
        s_set_prop _SURF_GO "$1"
-       # get the new name
-        name=`s_get_prop WM_ICON_NAME`
-       # loop until the [10%] stuff is finished and we have a load (is this necessary?)
-       #while echo $name | grep "[*%\]" >/dev/null 2>&1; do 
-       #       name=`s_get_prop WM_ICON_NAME`
-       #done 
-       # bail on error and don't store
-       #if [[ $name != "Error" ]]; then
-       #       uri=`s_get_prop _SURF_URI`
-               # store to the bmarks file the OFFICIAL url (with http://whatever)
-                s_write_f $bmarks "$1"
-               #grep "$uri" $bmarks >/dev/null 2>&1 || echo "$uri" >> $bmarks
-       #fi
+     s_write_f "$bmarks" "$1"
 }
 
 case "$pid" in
 "_SURF_INFO")
-       xprop -id $xid | sed 's/\t/    /g' | $dmenu -fn "$font" -b -l 20
+       @xprop@/bin/xprop -id "$xid" | @gnused@/bin/sed 's/\t/    /g' | dmenu_cmd -fn "$font" -b -l 20
        ;;
 "_SURF_FIND")
-       find="`tac $ffile 2>/dev/null | $dmenu -fn "$font" -b -p find:`"
+    find="$(@coreutils@/bin/tac "$ffile" 2>/dev/null | dmenu_cmd -fn "$font" -b -p find:)"
        s_set_prop _SURF_FIND "$find"
-       s_write_f $ffile "$find"
+       s_write_f "$ffile" "$find"
        ;;
 "_SURF_BMARK")
-       uri=`s_get_prop _SURF_URI`
-       s_write_f $bmarks "$uri"
+    uri=$(s_get_prop _SURF_URI)
+       s_write_f "$bmarks" "$uri"
        ;;
 "_SURF_URI_RAW")
-       uri=`echo $(s_get_prop _SURF_URI) | $dmenu -fn "$font" -b -p "uri:"`
+    uri=$(s_get_prop _SURF_URI | dmenu_cmd -fn "$font" -b -p "uri:")
        s_set_prop _SURF_GO "$uri"
        ;;
 "_SURF_URI")
-       sel=`tac $bmarks 2> /dev/null | $dmenu -fn "$font" -b -l 5 -p "uri [gxy*]:"`
+       sel=$(@coreutils@/bin/tac "$bmarks" 2> /dev/null | dmenu_cmd -fn "$font" -b -l 5 -p "uri [gynbwasx*]:")
        [ -z "$sel" ] && exit
-       opt=$(echo $sel | cut -d ' ' -f 1)
-       arg=$(echo $sel | cut -d ' ' -f 2-)
+       opt=$(echo "$sel" | cut -d ' ' -f 1)
+       arg=$(echo "$sel" | cut -d ' ' -f 2-)
        save=0
        case "$opt" in
        "g") # google for it
-               uri="http://www.google.com/search?q=$arg"
+               uri="http://www.google.com/search?q=""$arg"""
                save=1
                ;;
        "y") # youtube
-               uri="http://www.youtube.com/results?search_query=$arg&aq=f"
+               uri="http://www.youtube.com/results?search_query=""$arg""&aq=f"
                save=1
                ;;
+       "n") # mynixos.org 
+               uri="https://mynixos.com/search?q=""$arg"""
+               save=1
+               ;;
+    "b") # Brave Search
+        uri="https://search.brave.com/search?q=$arg"
+        save=1
+        ;;
+    "w") # Wiby 
+        uri="https://wiby.me/?q=$arg"
+        save=1
+        ;;
+    "a") # Anna's Archive
+        uri="https://annas-archive.gl//search?q=$arg"
+        save=1
+        ;;
+    "s") # SteamDB
+        uri="https://steamdb.info/search/?a=all&q=$arg"
+        save=1
+        ;;
+
        "x") # delete
-               sed -i "\|$arg|d" $bmarks
+               @gnused@/bin/sed -i "\|$arg|d" "$bmarks"
                exit;
                ;;
        *)
@@ -117,13 +120,13 @@ case "$pid" in
                ;;
        esac
        # only set the uri; don't write to file
-       [ $save -eq 0 ] && s_set_prop _SURF_GO "$uri"
+       [ "$save" -eq 0 ] && s_set_prop _SURF_GO "$uri"
        # set the url and write exactly what the user inputed to the file
-       [ $save -eq 1 ] && (s_set_prop _SURF_GO "$uri"; s_write_f $bmarks "$sel")
+       [ "$save" -eq 1 ] && (s_set_prop _SURF_GO "$uri"; s_write_f "$bmarks" "$sel")
        # try to set the uri only if it is a success
-       [ $save -eq 2 ] && s_set_write_proper_uri "$uri"
+       [ "$save" -eq 2 ] && s_set_write_proper_uri "$uri"
        ;;
 *)
-       echo Unknown xprop
+       echo Unknown @xprop@/bin/xprop
        ;;
 esac
index 90210a2e47eaa8a57e8b33cebd49f4fd920e49cc..39d3dcbd918ed85b03848a9ff6660abfca9cb32e 100644 (file)
         ]
       },
       "locked": {
-        "lastModified": 1777441132,
-        "narHash": "sha256-stXvTsRfrZjwdUR1ZrNOh3fUFG/b+1RoINoJBuWMRR0=",
+        "lastModified": 1777933639,
+        "narHash": "sha256-BMZmBTKFy8iab051rmXBHUZcfaav/c4GR9rpgdCR6XM=",
         "owner": "Skullheadx",
         "repo": "surf",
-        "rev": "e83b7c93f4f45bec608251b3b28273d6d3c2ab53",
+        "rev": "a9203494a3895f95a0207dabf7c587e60dab45c8",
         "type": "github"
       },
       "original": {
index f88127dbd76b9bf8073acca2e8ef2b4b3803458a..67a55f56c4e4de2d7921890963121a95e55609bd 100644 (file)
--- a/hjem.nix
+++ b/hjem.nix
   hjem.users.andrew = {
     directory = "/home/andrew";
     files = {
-
-      ".config/sxhkd/sxhkdrc".text = builtins.readFile (
-        pkgs.replaceVars ./dotfiles/sxhkd/sxhkdrc {
-          dmenu = pkgs.dmenu;
-          st = pkgs.st;
-          surf = pkgs.surf;
-          pamixer = pkgs.pamixer;
-          maim = pkgs.maim;
-          xdotool = pkgs.xdotool;
-          xclip = pkgs.xclip;
-          lockscreen = pkgs.lock-screen;
-          sfeed = pkgs.sfeed;
-          rmpc = pkgs.rmpc;
-          mpc = pkgs.mpc;
-          librewolf = pkgs.librewolf;
-        }
-      );
-
       ".config/surf/styles/default.css".source = ./dotfiles/surf/styles/default.css;
       ".config/surf/script.js".source = ./dotfiles/surf/script.js;
 
       lf
       sfeed
 
-      (pkgs.writeShellScriptBin "surf.sh" (
-        builtins.readFile (
-          pkgs.replaceVars ./dotfiles/surf/surf.sh {
-            dmenu = pkgs.dmenu;
-            xprop = pkgs.xprop;
-            gnused = pkgs.gnused;
-            coreutils = pkgs.coreutils;
-          }
-        )
-      ))
     ];
   };
 
index 6ae23ccfb2b83e3703f41d47958cc8be346b05de..8f51940f36f013479f6f2cd51fab484a99cd3671 100644 (file)
@@ -7,6 +7,11 @@
     (final: prev: {
       scrolling-title = import ./scripts/scrolling-title.nix { pkgs = prev; };
     })
+    (final: prev: {
+       surf_search = import ./scripts/surf_search.nix { pkgs = prev; };
+    })
+
+
     (final: prev: {
       slstatus = inputs.my-slstatus.packages.${pkgs.stdenv.hostPlatform.system}.default;
     })
diff --git a/scripts/surf_search.nix b/scripts/surf_search.nix
new file mode 100644 (file)
index 0000000..233a121
--- /dev/null
@@ -0,0 +1,17 @@
+{ pkgs }:
+pkgs.writeShellApplication {
+  name = "surf_search";
+  runtimeInputs = with pkgs; [
+            dmenu
+            xprop
+            gnused
+            coreutils
+  ];
+  text = builtins.readFile (
+          pkgs.replaceVars ../dotfiles/surf/surf.sh {
+            dmenu = pkgs.dmenu;
+            xprop = pkgs.xprop;
+            gnused = pkgs.gnused;
+            coreutils = pkgs.coreutils;
+          }
+        );}
diff --git a/todo b/todo
index 368158c110f34ba90433f680ef5bec109e93a5fd..b31754ab6fff75a8122384c89955534d639e7583 100644 (file)
--- a/todo
+++ b/todo
@@ -30,6 +30,7 @@
                - [x] get rid of missing spaces
                - [x] toggable transparency
         - [ ] clipboard
+        - [ ] open new window in current dir
        - [ ] vim
                - [ ] find a non ai fork? vim classic?
                - [x] line nums
diff --git a/x11.nix b/x11.nix
index 3ab3bb62cf4d4c0f6ee60d1243ba66ed7269dd99..28bb823a0d79d3b6d3e2f88d26d30568a648af72 100644 (file)
--- a/x11.nix
+++ b/x11.nix
   };
 
 
+  hjem.users.andrew = {
+    files = {
+      ".config/sxhkd/sxhkdrc".text = builtins.readFile (
+        pkgs.replaceVars ./dotfiles/sxhkd/sxhkdrc {
+          dmenu = pkgs.dmenu;
+          st = pkgs.st;
+          surf = pkgs.surf;
+          pamixer = pkgs.pamixer;
+          maim = pkgs.maim;
+          xdotool = pkgs.xdotool;
+          xclip = pkgs.xclip;
+          lockscreen = pkgs.lock-screen;
+          sfeed = pkgs.sfeed;
+          rmpc = pkgs.rmpc;
+          mpc = pkgs.mpc;
+          librewolf = pkgs.librewolf;
+        }
+      );
+    };
+  };
+
 systemd.user.services.sxhkd = {
   description = "Simple X Hot Key Daemon (sxhkd)";
+
+  path = with pkgs; [
+           dmenu
+           st
+
+           pamixer
+
+           maim
+           xdotool
+           xclip
+
+           lock-screen
+
+           sfeed
+
+           rmpc
+           mpc
+
+           surf
+           librewolf
+           surf_search
+  ];
   
   serviceConfig = {
     ExecStart = "${pkgs.sxhkd}/bin/sxhkd";