From 8f94201019867f86285b50bec72d82d23c57977c Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Sun, 26 Nov 2023 15:01:55 +0100 Subject: [PATCH] Add a script to search with duckduckgo --- modules/services/qtile/config.py | 1 + modules/services/qtile/default.nix | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/modules/services/qtile/config.py b/modules/services/qtile/config.py index d80b5df..c7be50a 100644 --- a/modules/services/qtile/config.py +++ b/modules/services/qtile/config.py @@ -60,6 +60,7 @@ keys = [ Key([mod], "e", lazy.spawn("nautilus")), Key([mod], "p", lazy.spawn("xrandr --auto")), Key([mod], "r", lazy.spawn("rofi -matching-negate-char \\0 -show run")), + Key([mod], "s", lazy.spawn("rofi-search")), Key([mod], "w", lazy.spawn("firefox")), Key([mod], "Tab", lazy.spawn("rofi -show window")), # Toggle between different layouts as defined below diff --git a/modules/services/qtile/default.nix b/modules/services/qtile/default.nix index b46a335..0963253 100644 --- a/modules/services/qtile/default.nix +++ b/modules/services/qtile/default.nix @@ -1,6 +1,20 @@ { config, lib, pkgs, ... }: let cfg = config.services.az-qtile; + rofi-search = pkgs.writeShellScriptBin "rofi-search" '' + # Use rofi to get user input + raw_user_input=$(echo "" | ${pkgs.rofi}/bin/rofi -dmenu -p "What do you want to search:") + user_input=$(${pkgs.jq}/bin/jq --raw-output --null-input --arg x "$raw_user_input" '$x|@uri') + + # Check if user provided input + if [ -n "$user_input" ]; then + # Execute your command with the user input as an argument + # Replace 'your_command' with the actual command you want to run + $DEFAULT_BROWSER "https://duckduckgo.com/?q=$user_input" + else + echo "No input provided." + fi + ''; in { options = { @@ -19,6 +33,7 @@ in home.file.".config/qtile/autostart.sh".source = ./autostart.sh; home.packages = [ pkgs.pulseaudio # required for volume controls in qtile + rofi-search ]; }; };