Solve Problems With Shell Scripting And Dmenu

  Рет қаралды 33,032

DistroTube

DistroTube

Күн бұрын

Пікірлер: 118
@JinxTheBorderCollie
@JinxTheBorderCollie 3 жыл бұрын
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.
@TheLinuxCast
@TheLinuxCast 3 жыл бұрын
IDK if this is for everyone, but in dmconf to get this to work outside of emacs, I had to change the DMEDITOR to 'st -e nvim' (also worked with termite) that way it would open up the terminal and then launch nvim.
@daveshouldaine2520
@daveshouldaine2520 3 жыл бұрын
hello and thx for an advice
@peterkruskopfs3626
@peterkruskopfs3626 3 жыл бұрын
@@daveshouldaine2520 thanks as I ran into the same issue. This fixes it.
@smeqwack7337
@smeqwack7337 3 жыл бұрын
goddam, ever since i learned about dmenu, rofi, shell scripting and other stuff i dont really have to open teriminals to do everyday stuff like changing the wallpapers or changing the color theme on pywal, is so nice. Specially when u can alias it or add it as a keyboar shortcut
@zvezdan956
@zvezdan956 3 жыл бұрын
what about system updates?
@Mathias-bz2kr
@Mathias-bz2kr 3 жыл бұрын
@@zvezdan956 i just use "alias uu="sudo apt update && sudo apt upgrade ""
@smeqwack7337
@smeqwack7337 3 жыл бұрын
@@zvezdan956 what's a system update?
@skye1596
@skye1596 3 жыл бұрын
Is that you in your wallpaper?
@raushonmunni2633
@raushonmunni2633 3 жыл бұрын
i thought the same thing
@GodIsTheReason
@GodIsTheReason 3 жыл бұрын
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.
@DistroTube
@DistroTube 3 жыл бұрын
I've been playing with a similar idea. A dmenu script that controls the deadbeef player, gets tracks info, or loads playlists.
@rafinhodivino5877
@rafinhodivino5877 3 жыл бұрын
pls share the code
@coffeedude
@coffeedude 3 жыл бұрын
That second script is actually a great idea!! I'm going to write a version of it myself to practice :)
@ricardopinho630
@ricardopinho630 3 жыл бұрын
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.
@primorock8141
@primorock8141 3 жыл бұрын
Played around with dmenu yesterday and there are so many possibilities; exaclty what I'd expect from suckless
@redgeoblaze3752
@redgeoblaze3752 2 жыл бұрын
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.
@zebbleganubi723
@zebbleganubi723 3 жыл бұрын
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
@ipws13
@ipws13 3 жыл бұрын
you save my time, already using your scripts, and edit it a little for my machine
@williammckeever4790
@williammckeever4790 2 ай бұрын
I know this is an older vid but I just discovered dmenu and this has helped me immensely. Thanks for sharing.
@StrikerEureka85
@StrikerEureka85 3 жыл бұрын
Dmenu: "do you have time to talk about our lord and savior, DT?"
@SubhadityaMukherjee
@SubhadityaMukherjee 3 жыл бұрын
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
@MarcelRobitaille
@MarcelRobitaille 3 жыл бұрын
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.
@leviticus8930
@leviticus8930 3 жыл бұрын
Dmenu has informed us that you have not extended your car's warranty
@drishalballaney
@drishalballaney 3 жыл бұрын
lool nice one
@toastybowl
@toastybowl 2 жыл бұрын
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
@temudjin1155
@temudjin1155 3 жыл бұрын
Love this channel. Simple. Straightforward.
@othernicksweretaken
@othernicksweretaken 3 жыл бұрын
What is the purpose of the hyphen in the 2nd field of your array's elements? Assuming the hyphen isn't a kind of placeholder for a field value to be populated later you could have used a "declare -A" instead declaring an associative array (or hash as called in Perl, or dictionary as called in Python) which would have saved you the pipe into awk to parse the value field of your array elements.
@othernicksweretaken
@othernicksweretaken 3 жыл бұрын
@Learn Linux Me too. Although in a script like this it doesn't really matter, I often imagine nested loops where command pipes in the inner loop could be executed many thousand times and where you want to avoid unnecessary forks of subshells. Have you heard of Randal Schwartz's _Useless Use of Cat Award_ ? This dates back three decades when dynamic content of many websites in the WWW was generated by often _Idiotic Perl_ scripts.
@Mach7RadioIntercepts
@Mach7RadioIntercepts 3 жыл бұрын
I was also wondering about that dash. My fzf / rofi radio bookmarks only use two fields. Luke Smith showed a nice way to break up those variables with # or % and using the dash may be more handy than splitting fields on the spaces.
@othernicksweretaken
@othernicksweretaken 3 жыл бұрын
@@Mach7RadioIntercepts Yes, I think what you mean is called parameter expansion. There should be a section in man bash explaining all sorts of variable expansions and pattern substitutions. This is by far the most efficient way of parsing because it is a shell built-in functionality and avoids invocation of any external commands to accomplish the task, as one usually does by piping into e.g. grep, sed, tr, awk, perl etc. e.g. If the value of an array element of DT's example was stored in ENTRY one could expand all after the hyphen referring to ${ENTRY#*-\ } likewise to expand all up to the hyphen by referring to ${ENTRY%\ -*}
@adriancostin9138
@adriancostin9138 3 жыл бұрын
good stuff. going to start writing scripts for my dmenu. thank you for showcasing this
@myownbasement
@myownbasement 3 жыл бұрын
@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?
@DistroTube
@DistroTube 3 жыл бұрын
I don't use screenlockers much on my on machines. And slock is a simple program. Not much to it. Install it. Run 'slock' to lock the screen. Start typing your password...if the screen is blue and unlocks, you typed your pass word correctly. If the screen turns red, then you entered the wrong password, try again.
@myownbasement
@myownbasement 3 жыл бұрын
@@DistroTube Oh is it? Thanks a lot for the reply. Love your content.
@starrwulfe
@starrwulfe 3 жыл бұрын
I’m so about to fork one of these scripts and make a crypto checker script now.
@marcello4258
@marcello4258 3 жыл бұрын
may I suggest using exit 0 instead of exit 1 when it is not an error?
@albynoson
@albynoson 3 жыл бұрын
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.
@piotrzieniewicz9045
@piotrzieniewicz9045 3 жыл бұрын
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?
@DistroTube
@DistroTube 3 жыл бұрын
My dmenu doesn't search the .desktop files. Usually this isn't a problem for me....except with appimages.
@kanashimi6209
@kanashimi6209 3 жыл бұрын
Very useful, thank you Derek. Keep it coming!
@kartikeykushwaha3622
@kartikeykushwaha3622 3 жыл бұрын
Hey DT, can you make a video on dmenu-flexipatch, dwm-flexipatch, st-flexipatch, etc?
@anzar4142
@anzar4142 3 жыл бұрын
Hey DT can you talk about ZFS.
@Adam-yf2ux
@Adam-yf2ux 3 жыл бұрын
Awesome ! Thanks for this video. I will play around with dmenu :)
@albynoson
@albynoson 3 жыл бұрын
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)
@JopiesausGaming
@JopiesausGaming 3 жыл бұрын
You might be able to use SteamCMD to create a list of installed games which gets read out by the dmenu script.
@albynoson
@albynoson 3 жыл бұрын
@@JopiesausGaming It later occured to me I don't need the executables or paths to the games, just their IDs and names. In the steamapps folder, there isn't one big repository, but rather, a file for each installed game called "appmanifest_(id).acf". They each contain an "appid" field and a "name" field. Any idea how I go about parsing these files one at a time whilst still making sure the names and IDs go together?
@JopiesausGaming
@JopiesausGaming 3 жыл бұрын
@@albynoson If you use "grep '\"appid\"\|\"name\"' $STEAMDIR/appmanifest_*" it should give a workable output, i am however not that competent in string manipulation in bash, so i wouldn't immediately know how to proceed from there.
@anantgupta7916
@anantgupta7916 3 жыл бұрын
What's your opinion on rofi run launcher
@vaibhavppandey
@vaibhavppandey 3 жыл бұрын
Bhai maine tere latest video me comment kiya hai dekhle. Aur haa rofi jyada customisable hota hai
@artificialcode
@artificialcode 2 жыл бұрын
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
@drishalballaney
@drishalballaney 3 жыл бұрын
hmm, what do you think of xmonad prompt compared to dmenu?
@DistroTube
@DistroTube 3 жыл бұрын
They are not really the same thing. The Xmonad prompt is part of Xmonad. It is not a standalone program like dmenu that you can incorporate into scripting.
@georgesomeone7725
@georgesomeone7725 3 жыл бұрын
Hey DT, nice content, thanks. Where can I get the wallpaper you're using in this vid?
@DistroTube
@DistroTube 3 жыл бұрын
Check the 'wallpapers' repo on my GitLab. (0213.jpg)
@nathbarbosa83
@nathbarbosa83 3 жыл бұрын
while using sxhkd the script open, but when I press enter on dmenu, it doesn't open the config file
@joecool169
@joecool169 3 жыл бұрын
What would I use to have vim open in the terminal for editing config files? DMEDITOR="What?"
@blank001
@blank001 3 жыл бұрын
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)
@sumnerd69
@sumnerd69 3 жыл бұрын
Nice seeing this type of videos again
@sebastienhebert6457
@sebastienhebert6457 3 жыл бұрын
Qutebrowser stores bookmarks in a text file, its easy to pipe in dmenu.
@andrewcarpin2850
@andrewcarpin2850 3 жыл бұрын
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
@DistroTube
@DistroTube 3 жыл бұрын
I was in dwm in this video. But in xmonad, just create a keybinding like: ("M-p s", spawn "bash /path/to/script") The above example assumes you use EZ keybindings. The keybinding in this example is a keychord, SUPER+p followed by 's'.
@andrewcarpin2850
@andrewcarpin2850 3 жыл бұрын
@@DistroTube Much appreciated! I really love EZ Keys. I really wouldn't want to go back to standard keybindings after seeing how easy EZ can be! I'm going to try my dmenu scripts again later like this amd see what happens. Thanks again!
@Ohmygodzilla
@Ohmygodzilla 3 жыл бұрын
Well done, will try it out later! Thank you very much for this information
@stumbling
@stumbling 3 жыл бұрын
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 [2] second [3] third" | dmenu | cut -d' ' -f1)"
@davidh.4944
@davidh.4944 3 жыл бұрын
Try using an associative array. Print and select just the index name, and use the string returned to recall the desired path: ===== declare -A options options[bash]=$HOME/.bashrc options[vim]=$HOME/.vimrc ...etc... choice=$( printf '%s ' "${!options[@]}" | sort | dmenu .... ) echo "${options[$choice]}" ===== [Edit: I almost forgot, associative arrays do not *sort* naturally, so it's best to include your own, to be sure you see them in alphabetical (or other desired) order.]
@marioschroers7318
@marioschroers7318 3 жыл бұрын
This is brilliant!
@sunriseleatherco.6587
@sunriseleatherco.6587 3 жыл бұрын
That is some great stuff right there!
@raynei
@raynei 3 жыл бұрын
any scripting guides?
@davidh.4944
@davidh.4944 3 жыл бұрын
There's the venerable old _Bash Advanced Scripting Guide_ , always a staple, but it's a bit obscure for newbies, and perhaps a bit outdated. The _Bash Guide For Beginners_ may be better for beginners. There are certainly a lot of other good newer ones out there now, findable with just a flick of the DuckDuckGo. And while they aren't "guides", per se, I highly recommend _Greg's Wiki_ and the _Bash Hacker's Wiki_ . They are both indispensable for learning how to code _properly_ and to avoid common pitfalls. If you do nothing else, read Greg's BashFAQ and Bash Pitfall pages before you dive too deep into your coding.
@raynei
@raynei 3 жыл бұрын
@@davidh.4944 thank you!
@shubhamdwivedi7766
@shubhamdwivedi7766 3 жыл бұрын
I automate tasks with shell scripting nice handy feature 😉
@darkarie
@darkarie 3 жыл бұрын
DT can I make this on Rofi too rigth?? 🧐
@DistroTube
@DistroTube 3 жыл бұрын
Sure. Where I pipe things into dmenu, just change it to pipe into rofi.
@darkarie
@darkarie 3 жыл бұрын
@@DistroTube cool!! thanks
@TrueWordsOfEternity
@TrueWordsOfEternity 3 жыл бұрын
I'm gonna have to look at your kill script and use instamenu / imenu with it maybe I'll let you know how it works out
@rizkyadiyanto7922
@rizkyadiyanto7922 3 жыл бұрын
pls let me know
@Johan.Molenberghs
@Johan.Molenberghs 3 жыл бұрын
Why do you exit 1 on quit? Is quitting an error?
@DistroTube
@DistroTube 3 жыл бұрын
No, it should be exit 0. Probably just me being lazy and copying exit 1 from another place. Will correct those on the next push.
@gabemurray5365
@gabemurray5365 3 жыл бұрын
I figured out what DT stands for ... Donald trump DT real name is donald trump
@Gabifuertes
@Gabifuertes 3 жыл бұрын
Derek Taylor is just his fake internet name.
@tonythai5991
@tonythai5991 2 жыл бұрын
Nop, DT is a strong password.
@n0kodoko143
@n0kodoko143 3 жыл бұрын
I watched your wallpaper vid already, this is the first time I've experienced visceral wallpaper envy. /sexy
@mesientomuchomejor2027
@mesientomuchomejor2027 3 жыл бұрын
Just as I was wondering how to make a nice menu to read books with zathura, what timing lol
@areg7182
@areg7182 3 жыл бұрын
rofi also does the same thing, but dmenu is lighter
@fabioramatis2373
@fabioramatis2373 3 жыл бұрын
Rofi is prettier
@TrueWordsOfEternity
@TrueWordsOfEternity 3 жыл бұрын
@@fabioramatis2373 instamenu is nicer then rofi too and backwards compatible with dmenu
@gradientO
@gradientO 3 жыл бұрын
rofi can use dmenu scripts
@LordOfWizardurl
@LordOfWizardurl 3 жыл бұрын
Hello DT you are the best❤️
@DistroTube
@DistroTube 3 жыл бұрын
Hey, thanks!
@vorrnth8734
@vorrnth8734 3 жыл бұрын
Why "exit 1"? That should be a zero imo.
@DistroTube
@DistroTube 3 жыл бұрын
Yep.
@daviddupoise6443
@daviddupoise6443 3 жыл бұрын
Making dinner.
@brknglss7741
@brknglss7741 3 жыл бұрын
@8:20 free julian assange
@karthickb1973
@karthickb1973 3 жыл бұрын
shame on americans. they leave a solider alone in the battle field. all they care is themselves. democracy fails.
@svenkarlsen2702
@svenkarlsen2702 3 жыл бұрын
I use YAD in much the same way
@svenkarlsen2702
@svenkarlsen2702 3 жыл бұрын
@Learn Linux For simple things it's great... For more advanced stuff I'd use C++ and GTK instead of fighting with pipes and redirection...
@kevinwood5048
@kevinwood5048 3 жыл бұрын
Excellent! 👏👏👏
@librereader
@librereader 3 жыл бұрын
the best thing is to use fzf with dmenu
@charlessmith5465
@charlessmith5465 3 жыл бұрын
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.
@cam0227
@cam0227 3 жыл бұрын
Why gitlab instead of github? Can someone explain edit: got it so github belongs to micro$hit now
@wikingagresor
@wikingagresor 3 жыл бұрын
recently github was swallowed by microsoft, so the more weary folk migrated into new foss site.
@brknglss7741
@brknglss7741 3 жыл бұрын
github belongs to microsoft
@nykal1510
@nykal1510 3 жыл бұрын
@Learn Linux I prefer Codeberg
@cam0227
@cam0227 3 жыл бұрын
@@wikingagresor So why is kernel development still on github?
@vorrnth8734
@vorrnth8734 3 жыл бұрын
@@cam0227 Why not? Before git it used proprietary tool too.
@ronaldomessi6161
@ronaldomessi6161 3 жыл бұрын
One doubt any BEST free resources to learn shell scripting from the entry level to high level in the field of CYBERSEC OR HACKING LINE??? CAN YOU HELP ME ON THIS ???
@ahmedabd2259
@ahmedabd2259 3 жыл бұрын
That’s great
@falx966
@falx966 3 жыл бұрын
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! :)
@randomuser5237
@randomuser5237 3 жыл бұрын
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.
@DistroTube
@DistroTube 3 жыл бұрын
Who says you have to use Emacs with this script?
@v1ntee
@v1ntee 3 жыл бұрын
Shell scripting with Dmenu? are you friend of that guy named Luke? 🤣
@OctaviusPelagius
@OctaviusPelagius 3 жыл бұрын
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...
2 жыл бұрын
If I have my dm-record (copy of yours) in my ~/.dotfiles/bin how can I call it from dmenu?
Creating A Dmenu Script For Web Bookmarks And History
17:13
DistroTube
Рет қаралды 9 М.
A Linux Shell Prompt That's Out Of This World!
13:30
DistroTube
Рет қаралды 187 М.
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
Gen AI EXPERT Reveals 19 Predictions for 2025
18:17
minhsmind
Рет қаралды 8
What Are Linux Users Putting In Their Config Files?
31:47
DistroTube
Рет қаралды 93 М.
Want A List Of Your Keybindings? Write A Shell Script!
27:11
DistroTube
Рет қаралды 24 М.
The New Outlook is TERRIBLE
20:19
Chris Titus Tech
Рет қаралды 120 М.
dmenu: Your own Custom Script Menus!
10:29
Luke Smith
Рет қаралды 139 М.
How To Build Your First RAG/Chatbot With Python (For Beginners)
15:31
Fix Your Shell Scripts With Shellcheck
11:18
DistroTube
Рет қаралды 14 М.
Learning Sed Is Beneficial For Linux Users
19:27
DistroTube
Рет қаралды 87 М.
Turn Your Window Manager Into A Desktop Environment
16:47
DistroTube
Рет қаралды 143 М.
The 12 Linux Apps Everyone Should Know About
21:20
DistroTube
Рет қаралды 479 М.