 In the last couple of weeks, I spent a lot of time trying to clean up some of my GitLab projects, been putting in a lot of work, especially as I improve some of the stuff that is associated with DTOS, which is my Arch Linux post installation script. And one of the things I've really put in a lot of work in here in the last couple of weeks is my DM scripts. So DM scripts, essentially, it's a collection of Dmenu scripts. It's about 30 different scripts designed to be used in conjunction with Dmenu. I've got DM scripts packaged for the Arch user repository, the AUR. DM scripts is also a package that is installable if you have DTOS installed, because it's actually in the DTOS core repository. And one of the things that I've always had as an option in DM scripts is the ability to easily swap Dmenu for ROFI if you would rather use ROFI with all of these scripts rather than Dmenu. Well, that's always been kind of neat. But Dmenu and ROFI, it kind of makes sense to be able to swap between them, because they're essentially the same kind of program. A graphical program, they have the same flags and options for the most part, and they do the same things. But the other day, I made a video about FZF Fuzzy Finder, which is a little different. It's very similar to Dmenu and ROFI, but it is a terminal application. It doesn't draw its own X window. It has to be run in a terminal application. But Fuzzy Finder, I think, is really neat. And I got to thinking, wouldn't it be neat if I could make DM scripts also be able to use Fuzzy Finder if you so choose. So if you're running one of the DM scripts in a terminal, you could just use Fuzzy Finder instead of Dmenu or ROFI. So let me show you a little bit of what I've got in mind here. If I switch over to my desktop here, this is my config file for DM scripts. So DM scripts, you've got the 29 or 30 individual shell scripts, bash scripts that launch each of the individual DM scripts. But they do all have a shared config file that is simply called config. That's going to live in .config slash DM scripts slash config. That's where this file should be placed on your system. And there's several variables assigned in this config. There's also several arrays that are listed here. And the reason this is done in this config file, it just makes it so much easier for everybody to personalize their individual use cases for these DM scripts. For example, if you didn't want to use Dmenu, you could always instead do Dmenu equals ROFI dash Dmenu. And then just comment out this line if you wanted. So that's a very easy swap, but it's a little clunky, especially now that I also want to add FZF, Fuzzy Finder, as an option. So what I've decided to do is I'm going to add three different variables to the config file. I'm going to have a Dmenu variable for Dmenu, Fmenu for Fuzzy Finder, and Rmenu for ROFI. And I'll show you why I need all three of these in the config file in just a second. So I'm going to do space period here inside doomymax to run the find file command. I'm going to go up one directory and I'm going to go into DM scripts slash scripts. So this is my DM scripts repository locally on my machine. And I have picked out this script to work with the DM hub script. And by default in DTOS, the DM hub script, if you do super P H for hub, this is simply a Dmenu of all the DM scripts. Each individual DM script is listed here. If I picked another one, like DM dash color pick, I get this where if I hit orange, it copies the color that I have set for orange in my terminal color screen or whatever I happen to be using for that. It copies that to the clipboard. And all of these DM scripts are kind of designed the same way. I've specified kind of a style guide as far as they should all have the same kind of header. They should all be written with the user bin env bashabang. So if you use bashisms, that's great. They should all include the name of the script, a description, the dependencies, and then of course the location of the get lab. Which in this case, I notice in this script, it's not quite right. That should be DM scripts there. And then any contributors, which these are the guys that originally wrote this. And since I've made some major changes here, I probably should add my name. So I'll go ahead and add my name as well. And then every single DM script is going to have set dash EUO pipe fail. And that's done for debugging purposes. So if the script fails, it'll help us out a little bit. And then we've also got this section also in every single DM script. So there is a little helper shell script that contains some custom functions that can be used within each individual DM script. And then we also source our config file. So if you have that file located in your home directory slash dot config slash DM script slash config, it's going to source that config. And then after that is the actual individual script code itself. So what this DM hub script does, it essentially takes all of the DM scripts that are located in the repository. It goes and finds all the individual script names. So if I do super P H again, it just prints out those names. And because every single script has that description comment in the header. Because remember, I'm making everybody follow the same style guide. I also include the description out to the side of the name because I can pull out that description. And I do that, of course, using standard shell utilities such as grip. You can see I'm searching for the description. Let me turn on truncated lines here because things are running off the side of the page. Yeah, that looks a lot better. So the way the script used to look, it used to have a variable here called demenu because demenu was the only menu variable in the config file. If you wanted to use Rofi, you would just change the demenu variable in the config to be demenu equals Rofi, right? But that doesn't quite work with what I'm thinking. Now I'm going to have this menu variable, which is not assigned in the config. Remember, in the config, I have three different variables. I have demenu, fmenu and rmenu. What I'm going to do is when the script actually gets executed, now I'm going to have while get ops and then D, F, R, H. So get ops. So I'm going to be able to pass an option to the command. So when I run dm-hub, which is the name of this particular script, I can pass it a dash D flag, a dash F flag, a dash R flag, or a dash H flag. So that is what's going on in this loop, this while get ops and then the flags. And then inside the while loop, I have a case statement. So case, arg, so whatever argument, so each individual argument will do a different thing. If I give you D, the dash D flag, then I want to assign that menu variable that was up here earlier in the script, this menu variable. I want you to assign menu to actually be the demenu variable because we source that config that has the demenu variable. And if I give you the F flag, I want menu to equal the F menu variable that's in the config. If I give you the R flag, I want the menu variable to equal the R menu variable that's in the config. And if I give you the H flag, I just want you to run the help function. So I added a little help function here and we're near the top that just gives you some help information. Now, if I did this correctly, let me open a terminal and see if I did this correctly. So zoom in here and I'm a CD into my DM scripts directory. And if I run this DM dash hub script with no argument, it's going to run with demenu. And the reason it runs demenu, if I don't give it an argument, is because back here inside the script, it says, well, get ops, right? So if I give it a flag, do this. But I also needed to also give it this kind of base statement. Hey, what if I don't pass it any options? Well, you can see no opt equals one. So if I don't give it any options, then I want you to just run menu equals demenu. So assign the menu variable to be demenu and then run the main function. Which is actually running the script. So let me get back out of that and go back here. So if I up arrow and run DM dash hub dash H for the help flag, there is the help information. It just gets printed here to the terminal. If I give it dash D for demenu, it runs DM hub using demenu. If I give it dash R for Rofi, it runs DM hub using Rofi. And if I give it dash F, it runs DM hub using fuzzy finder inside the terminal. Let me escape out of that. How cool is that? Now, this really wasn't that complicated to do this. And now I would have to go in and edit all of the individual 30 or so DM scripts. It's actually not a complicated edit. All I would have to do is add this while get ops thing right to each script. And then I may have to edit exactly the functions they run depending on the options or whatever. But this would probably take me, I don't know, a few hours to set this up for all 30 of the individual DM scripts right now. I've only got it working with DM hub just as proof of concept. And I thought it was kind of neat. I wanted to share it with you guys on camera. Because I know a lot of you guys probably have demenu scripts, Rofi scripts, fuzzy finder scripts, or maybe other kinds of scripts that you could easily swap out certain things that get run when you execute these scripts. Maybe you want to be able to swap between certain programs that open certain things. Maybe you have a script that opens, I don't know, PDFs. And maybe you want those PDFs to open in certain kinds of programs depending on a flag or an option you give it. Well, you can do this stuff with this while get ops loop. So I'm going to have to spend a few hours of work on this, obviously, because I've still got a lot of testing to do. I want to make sure that all of the individual DM scripts, all 30 of them or so, actually do work in all three formats, demenu, Rofi, fuzzy finder. Obviously, some of the scripts are not going to be able to be used with fuzzy finder. For example, some of the DM scripts are based on graphical programs. Like, I've got DM scripts that search the web. For example, they'll give it a search query. And then it opens the results of that inside a web browser. Well, that's not going to work if you're not inside a graphical environment. That wouldn't work at a TTY if it's trying to open Firefox, for example. But I mean, you could probably edit the script to just substitute the browser for a terminal-based browser. So even that, you can get around some of that stuff. Ultimately, I'm envisioning DM scripts to be much more flexible, customizable, extensible. I don't want it to be rigid. I don't want people to have to use a particular run launcher or particular browser, particular text editor. I want people to be able to use these scripts in whatever manner they want to be. I think that's important for software development. So that's the plan for DM scripts going forward. You're going to have flags and options to launch it with demenu, Rofi, or fuzzy finder. And I will eventually get this packaged up and pushed as a new major release for the AUR and for those of you that have the DTOS Core repository installed on your system. I'll probably have this live and working for all the DM scripts, probably within the next week. Now, before I go, I need to thank a few special people. I need to thank the producers of this episode. Gabe James Maxim, Matt Mitchell, Paul Royal West, Armored Dragon, Bash Potato Chuck, Commander Angry George, Lee Methos, Nate Erion, Paul Peace, Archon Petour, Polytech Realities for Less Red Prophet, Roland Tools, Devlin, and Willie. These guys, they're my highest tiered patrons. Over on Patreon, without these folks, I couldn't do what I do. I also want to thank each and every one of these fine ladies and gentlemen, and all these names you're seeing on the screen right now. Each and every one of these ladies and gentlemen, these are all my supporters over on Patreon because I don't have any corporate sponsors. I depend on you guys. If you like my work, want to see more videos about Linux and free and open source software, subscribe to DistroTube over on Patreon. Peace. There's so much work to do, so little time.