[qutebrowser_dmenu.pl]: Add qutebrowser_dmenu.pl

This commit is contained in:
2025-04-16 18:07:05 +01:00
parent ea454575ac
commit 791671a31c
2 changed files with 41 additions and 0 deletions

View File

@ -16,6 +16,7 @@
- `music_dmenu.sh`: script to play a specific artist, album, or track selected with dmenu.
- `play_music.sh`: simple script to play music albums based off the supplied artist & album name.
- `qutebrowser_search.sh`: script that finds all the search engines defined in the qutebrowser `config.py` configuration file and makes them available for searching via dmenu, i.e. allow web searching with qutebrowser without having to wait for it to start up before you start your search.
- `qutebrowser_dmenu.pl`: script that constructs a `dmenu` menu of all search engines defined in the `qutebrowser` configuration file for searching without first launching `qutebrowser`.
- `repos_checker.sh`: script to find all of the Git repositories in the current directory & its sub-directories and display each found repository's `git status`.
- `screenshot.sh`: screenshot script for both Xorg and Wayland with selection that both saves the image file and adds the image to the clipboard, and notifies the user via `notify-send`.
- `stdin_to_notis.sh`: scripts that reads from `stdin` and sends each line as a system notification. Intended for use when a program that outputs to `stdout` is called from a non-terminal or graphical program, making the `stdout` output inaccessible. The output can instead be piped into this script to make it readable as a system notification.

40
src/qutebrowser_dmenu.pl Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/perl -l
# Script that constructs a `dmenu` menu of all search engines defined in the qutebrowser configuration file for searching without first launching qutebrowser
use strict;
use warnings;
my $file_path = "$ENV{HOME}/.config/qutebrowser/config.py";
my @search_engines;
open(my $file_handler, '<', $file_path) or die("Couldn't open $file_path $!");
my $inside = 0;
while (my $line = <$file_handler>) {
if ($line =~ /^c\.url\.searchengines\s*=\s*{/) {
$inside = 1;
next;
}
if ($inside) {
last if ($line =~ /^\s*}/);
$line =~ s/["':]//g;
$line =~ s/^\s+|\s+$//g;
my ($search_engine) = split(/\s+/, $line);
if ($search_engine && $search_engine !~ /^\s*#/) {
push(@search_engines, $search_engine);
}
}
}
close($file_handler);
my $dmenu_input = join("\n", @search_engines);
my $selection = `echo "$dmenu_input" | dmenu`;
if ($selection) {
exec("qutebrowser", $selection);
}