Solve Problems With Shell Scripting And Dmenu

Solve Problems With Shell Scripting And Dmenu

DistroTube

4 года назад

33,938 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@StrikerEureka85
@StrikerEureka85 - 09.03.2021 07:34

Dmenu: "do you have time to talk about our lord and savior, DT?"

Ответить
@SubhadityaMukherjee
@SubhadityaMukherjee - 09.03.2021 08:27

So I threw a small shell script together to edit my configs. Its relatively easier to understand. All you have to do is dump your paths in one file line by line. (Replace nvim/nnn and the path with whatever you want).
Thought it would be helpful.

PS. DT. Love your channel so much! I learnt a lot from it. Thank you for your content :)

#!/usr/bin/bash
choice=$(cat "/home/eragon/Documents/scripts/listofscripts.txt" |dmenu -l 10)
echo $choice
if [ -d $choice ]
then
echo "Directory"
nnn $choice
else
echo "File"
nvim $choice
fi

Ответить
@albynoson
@albynoson - 09.03.2021 09:41

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)

Ответить
@skye1596
@skye1596 - 09.03.2021 09:58

Is that you in your wallpaper?

Ответить
@LordOfWizardurl
@LordOfWizardurl - 09.03.2021 10:28

Hello DT you are the best❤️

Ответить
@albynoson
@albynoson - 09.03.2021 10:59

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.

Ответить
@FrasSmith
@FrasSmith - 09.03.2021 13:25

If anyone wants to use these with rofi, it's a very simple find and replace: Find "dmenu", Replace with "rofi -dmenu".

Ответить
@81tch
@81tch - 09.03.2021 13:37

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! :)

Ответить
@kartikeykushwaha3622
@kartikeykushwaha3622 - 09.03.2021 15:12

Hey DT, can you make a video on dmenu-flexipatch, dwm-flexipatch, st-flexipatch, etc?

Ответить
@Johan.Molenberghs
@Johan.Molenberghs - 09.03.2021 15:34

Why do you exit 1 on quit? Is quitting an error?

Ответить
@sunriseleatherco.6587
@sunriseleatherco.6587 - 09.03.2021 16:16

That is some great stuff right there!

Ответить
@vorrnth8734
@vorrnth8734 - 09.03.2021 16:48

Why "exit 1"? That should be a zero imo.

Ответить
@darkarie
@darkarie - 09.03.2021 16:50

DT can I make this on Rofi too rigth?? 🧐

Ответить
@JinxTheBorderCollie
@JinxTheBorderCollie - 09.03.2021 16:57

DT, this is one of the most useful videos you have done. Videos like this, describing simple tools that have far-reaching uses is something we need more of. Please.

Ответить
@n0kodoko143
@n0kodoko143 - 09.03.2021 17:05

I watched your wallpaper vid already, this is the first time I've experienced visceral wallpaper envy. /sexy

Ответить
@ricardopinho630
@ricardopinho630 - 09.03.2021 17:41

That's incredible. I'm going to steal the code. I'm getting into Linux for the past year or so and I've been learning much in this channel. Nice as well been joining this Linux community as an escape from the madness all over the mainstream web platforms.

Ответить
@sumnerd69
@sumnerd69 - 09.03.2021 18:16

Nice seeing this type of videos again

Ответить
@stumbling
@stumbling - 09.03.2021 18:25

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)" <<< "[1] goat
[2] cheese
[3] ham" | cut d' ' -f2

Ответить
@andrewcarpin2850
@andrewcarpin2850 - 09.03.2021 20:06

What is it that you put in your Xmonad config to launch these scripts? I've tried creating a few of these and they always launch kind of buggy

Ответить
@ganainm01
@ganainm01 - 09.03.2021 22:04

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: " <<<$(printf "%s\n" ${!configs[@]}))]}

Ответить
@piotrzieniewicz9045
@piotrzieniewicz9045 - 09.03.2021 23:07

Hey DT, do you use dmenu as your launcher? If so, do you use the path version or do you have a script that's working with .desktop files?

Ответить
@myownbasement
@myownbasement - 09.03.2021 23:29

@DistroTube Do you use any lockscreen?I have been through your dotfiles but didn't anything that mentioned slock, xscreensaver etc? Do you mind making a video on it?

Ответить
@GodIsTheReason
@GodIsTheReason - 09.03.2021 23:32

I made a simple script to search songs from my music folder by filename pattern, select with dmenu, and queue it to my playlist. It's the best thing since sliced bread.

Ответить
@Gabriel.Murray
@Gabriel.Murray - 10.03.2021 02:46

I figured out what DT stands for ... Donald trump
DT real name is donald trump

Ответить
@OctaviusPelagius
@OctaviusPelagius - 10.03.2021 04:24

No witty message at the end? I feel like waiting for a post-credits scene on a movie only to be yelled at to get out of the theater...

Ответить
@ipws13
@ipws13 - 10.03.2021 05:06

you save my time, already using your scripts, and edit it a little for my machine

Ответить
@sebastienhebert6457
@sebastienhebert6457 - 10.03.2021 05:10

Qutebrowser stores bookmarks in a text file, its easy to pipe in dmenu.

Ответить
@MarcelRobitaille
@MarcelRobitaille - 10.03.2021 19:22

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.

Ответить
@rostart123
@rostart123 - 10.03.2021 20:46

I automate tasks with shell scripting nice handy feature 😉

Ответить
@temudjin1155
@temudjin1155 - 11.03.2021 01:49

Love this channel. Simple. Straightforward.

Ответить
@kanashimi6209
@kanashimi6209 - 11.03.2021 03:35

Very useful, thank you Derek. Keep it coming!

Ответить
@Ohmygodzilla
@Ohmygodzilla - 11.03.2021 15:35

Well done, will try it out later! Thank you very much for this information <3

Ответить
@librereader
@librereader - 11.03.2021 22:41

the best thing is to use fzf with dmenu

Ответить
@primorock8141
@primorock8141 - 13.03.2021 06:32

Played around with dmenu yesterday and there are so many possibilities; exaclty what I'd expect from suckless

Ответить
@v1ntee
@v1ntee - 16.03.2021 13:20

Shell scripting with Dmenu? are you friend of that guy named Luke? 🤣

Ответить
@randomuser5237
@randomuser5237 - 10.04.2021 12:11

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.

Ответить
@joecool169
@joecool169 - 09.05.2021 21:23

What would I use to have vim open in the terminal for editing config files? DMEDITOR="What?"

Ответить
@zebbleganubi723
@zebbleganubi723 - 02.06.2021 17:09

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

Ответить
@adriancostin9138
@adriancostin9138 - 12.06.2021 22:45

good stuff. going to start writing scripts for my dmenu. thank you for showcasing this

Ответить
@imhemish
@imhemish - 31.07.2021 08:28

d search is actually availalbe in chromium browsers. you can edit your search engines and can include shebangs or just triggers when to activate one

Ответить
@marcello4258
@marcello4258 - 26.10.2021 15:59

may I suggest using exit 0 instead of exit 1 when it is not an error?

Ответить
@blank001
@blank001 - 05.11.2021 06:32

Thanks DT for this
I need to move some of my configs to dmenu, right now I have 7~8 aliases for config edits like
vi_zsh // for zsh config
vi_vi // vim config
vi_(etc)

Ответить
@Adam-yf2ux
@Adam-yf2ux - 06.11.2021 07:17

Awesome ! Thanks for this video. I will play around with dmenu :)

Ответить
@nathbarbosa83
@nathbarbosa83 - 16.11.2021 19:10

while using sxhkd the script open, but when I press enter on dmenu, it doesn't open the config file

Ответить
@toastybowl
@toastybowl - 08.01.2022 03:36

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

Ответить
@redgeoblaze3752
@redgeoblaze3752 - 06.05.2022 12:20

I'm actually having a lot of fun just trying to shell script my way into getting the perfect Desktop environment out of my Window Manager.
Just earlier today, I made a script that reads your steam game folder, then generates a Rofi menu to choose between these games.
I came up with a script that sets some certain color configs to constantly be cycling in a rainbow style. I'm not even going to use that, but it was fun to make.
I've got a ton of these ideas just to mess around with, and this video gave me a few more.
It really is a good way to learn shell scripting.

Ответить
@artificialcode
@artificialcode - 29.08.2022 20:50

Feel so sorry for the first script man, I mean I could do that in a loooott less, just using la on .config or anything else, greppping things I want , output that to a file, and use sed and tr and cut maybe to just format it. (I know it sounds complicated but in essence this will take like 2 or 3 lines max

Edit: the second script is similar to the first but makes much more sense in the second, the first would be much easier

Ответить
- 24.09.2022 20:24

If I have my dm-record (copy of yours) in my ~/.dotfiles/bin how can I call it from dmenu?

Ответить
@williammckeever4790
@williammckeever4790 - 05.10.2024 22:40

I know this is an older vid but I just discovered dmenu and this has helped me immensely. Thanks for sharing.

Ответить
@əöü
@əöü - 31.05.2025 01:50

dmenu kinda sucks, very slow

Ответить