VehiclesFashionRecipesBlogsHuntTravelsSportFunHandmadeITEducation
Mini-Games
x

x
zakruti.com » IT - Software » IT, programs, coding
Solve Problems With Shell Scripting And Dmenu DistroTube

Solve Problems With Shell Scripting And Dmenu DistroTube

FBTwitterReddit

video description

Rating: 4.0; Vote: 1
Solve Problems With Shell Scripting And Dmenu DistroTube While dmenu is a great way to launch your programs, dmenu is much more than just a run launcher. You can have shell commands output to dmenu. This makes dmenu a fantastic tool to incorporate into your shell scripts. - https://tools.suckless.org/dmenu/ - Dmenu - https://gitlab.com/dwt1/dmscripts - DT's scripts
Date: 2022-03-30

Comments and reviews: 10


You should check out how sxmo (simple X11 mobile) uses dmenu on the PinePhone. I originally typed a comment with some examples, but I clicked something that took me away from this video which then erased my two paragraphs of text, so look at their scripts yourself.
Their dmenu scripts that are run based on the X window title are cool and remind me of Microsoft's UWP menuing system. Although I believe for that system to work, developers had to code their application to use their proprietary menu system API, but these dmenu scripts are implemented in an extensible unix fashion: all selecting the options presented by dmenu does is send key combinations to your applications, so I could rewrite the script to list whatever entries with whatever keystrokes I want.

reply

Cool video. Lately I've been thinking about writing a dmenu scripts that launches Steam games without the need to open the Steam library window. Maybe with this tutorial I'll try it soon. I wish there were a way for the script to update itself, but I don't think there's a Steam file I can easily parse to automatically find games installed via Steam.
On another note, do you recommend a good dmenu script that can parse .desktop files but unlike i3-dmenu-desktop works with any window manager like, oh I don't know dwm, the actual tiling window manager made by the same suckless guys as dmenu itself? (what were the i3 guys thinking hard coding i3-dmenu-desktop to integrate with i3)

reply

I recently made my first rofi script, which replaces -Open with NVIM- in the right click menu with a script that finds all your open NVIM sessions and opens the file in the one you pick with nvim-remote. I usually navigate files in the terminal of course, but this can be useful when downloading files from the browser. I live in tmux and usually have a lot of sessions open. If I'm working on something I don't want it to open a new terminal, the file is probably related to something I'm already working on.
reply

ive been meaning to make up some rofi/dmenu scripts for a while now. things like selecting multiple files and then choosing in the menu which scripts to send the file list to. like renaming or removing certain characters, resizing images, converting videos etc, there really is tons of things you can do. and the beauty of it all is that you only have to write each script one, then give it a descriptive name. beats having to remember all of the commands off the top of your head and having to type them out
reply

I think learning a POSIX shell is way better then Bash. Why? Simple. That script can be runned on different OS's like BSD, Solaris, AIX, HP-UX, etc., not just on GNU/Linux where bash is the default shell. Beside Bourne Shell code is more elegant the bash. I have scripts which run on FreeBSD, OpenBSD, Solaris, HP-UX and GNU/Linux without the need of modification. They just run.
#!/bin/sh. This is the way! :)

reply

I wish dmenu had an option to specify a separate output list, so for DT's dmconf script he could just display
-alacritty awesome bash...-
but selecting one of them would return the file path.
Here is my scrappy solution:
grep -$(echo -e -[1] first\n[2] second\n[3] third- - dmenu - cut -d' ' -f1)-

reply

Using awk to select a field is overkill!
I once created an similar script that uses associative arrays in bash and avoids subshells (pipes):
configs=(zprofile -$XDG_CONFIG_HOME/zsh/.zprofile- Xresources -$XDG_CONFIG_HOME/X11/Xresources- ...)
$EDITOR $-configs[$(dmenu -l 20 -p -Edit config: -

reply

What's the point of the first script? You're using emacs for editing all config files. Just use named bookmarks that is available in vanilla emacs (use a namespace format like config/bookmarkname to easily find config files). With Helm and other fancy stuff it's trivial to setup a better menu.
reply

This is very sick. I have looked for this kind of thing many times and this version seems to be very simple + useful.
Very nice examples as well - this is in the top 5 most useful ideas of computer use I think & definitely want others to learn this

reply

I have a version of dmenu_run which only shows a subset of the commands, instead of all executables in PATH. For example I never want to launch -true-, -false-, -dd-, or -[- from the desktop (without args) - instead it just shows things I tend to launch.
reply
Add a review, comment






Other channel videos