 Hey everybody, welcome back to the channel. Today I'm going to be talking about how you can create a script to access your browser bookmarks through Dmenu or Rofi. So I got this idea from DT who created a bunch of Dmenu scripts that are really cool. You should definitely check that out. I'll link that video in the description. And I'm going to use quite a bit of his syntax today to create my script. So I will show you how to do this with both Dmenu and Rofi, but in the end I'll be doing a Rofi version because I use Rofi and not Dmenu. But let's go ahead and jump in. Now you could easily use a program called Buku and I've done a video on Buku before. But for some reason Buku has stopped working for me so I've just decided to create my own. So the first thing I want to do is create the file that I'm going to be using. So I'm going to do touch vm.sh and then I'm going to make it execute by doing chmod a plus x bm.sh. I think actually I need to zoom in just a little bit here. Make sure you can see. And then I'm going to vm into it. So I'm going to do vm into bm.sh. Now we need to make this a shell script. So that means it needs a shebang at the beginning. And there are several shebangs that I could use but I'm going to use bash. So I'm going to do pound sign exclamation point slash user slash bin slash bash. We'll just do sh that'll be fine. And then the next thing I want to do is declare a browser variable. Now you can make this pretty much anything you want that is a browser of some kind. So you can use Firefox like I'm going to do. You can use Brave, Chromium, whatever. All you got to do to do that is just do editor, excuse me, not editor. You need to do browser equals quotation marks Firefox and make sure you spell it right because I don't know how to type. So the next thing I want to do is basically create a list of the bookmarks that you want to be able to access. So you need to do that through an array, which you do by doing this declare dash a and then options. So this is going to be basically declaring a variable called options that we will be able to call later on and pass through to D menu. And we want to do equals and then parentheses and then we'll create some space here. And then then you just want to basically do a line separated list of your bookmarks. So I'm just going to put in a couple here. So I'm going to do quotation marks HTTPS. Actually what I'm going to do is do I'm going to number these so that there's three fields. So one dash HTTPS colon backslash backslash YouTube dot com. Okay. And then I'm just going to take Yankees and then paste it so a few times and then just do use letter two, three, four, five, six, and then change word Facebook dot com. Actually make sure I spell this right and then change word Reddit dot com. Change word. Let's see here monkey type comm is another one that I use. Another one will actually do a dedicated one for UNIX porn because I go to UNIX porn way more than is healthy for anybody slash r slash units porn. Okay. We'll do github dot com. Okay. And then we can delete the extra spaces. Okay. And then we're going to want to go through and paste this in or pass this through to D menu. So in order to do that, we want to do this here. So we need to go back into insert mode and do choice. So whatever the the my choice is, I want to do dollar signs that's basically calling a variable called print F parentheses print F single quotes percent slash, excuse me, forward slash N. Okay. And then quotation marks, dollar sign, squirrely brackets options. So this is the variable from our array. Brackets zero or excuse me, that, that sign. Okay. And then that ends there. And then we want to go through and do pipe. So I'm going to show you how to do it with the menu first. And then I'll also go then I'll go through and change it for Rofi so you can do both. So we'll do D menu dash I dash L. So this basically means that it's going to be the dash I searches for things that are, I can't remember what it's called. It basically goes through and searches for things so that they're not exact matches. It doesn't require you to be typing in the case sensitive case sensitive is what I'm looking for. Hard words. Okay. The next is we want to give a number of values to display. So I'm going to put 20 and then dash P. That basically means it's dash P is being, it's being passed an argument or this is the prompt excuse me. And then the prompt that we want to use, which is bookmark. And then end the quotation marks and the parentheses. Actually what I'm going to do is create another one up here called quit seven. Dash quit. Actually, I think I just do quit. All right. And then we can do another one. We want to do an if statement here. So if if double brackets quotation marks dollar sign choice does not if it equals quit semi colon then echo program terminated and and exit loops one. Okay. And then what we're going to want to do is do then or excuse me, that's wrong. Else if and then bracket and then question quotation marks dollar sign choice. Okay. So basically so far this is if our choice is this last option here quit, then it's going to quit the program else that's going to take the choice that we've made and use that in a and then it's going to excuse me, it's going to take the choice that we've made and select the URL using Ock and pass it to the browser. Okay. So we want to do colon semi colon then CFG equals dollar sign parentheses print F single quotes percent S forward slash N question quotation marks dollar sign, scrolling brackets choice and then Ock excuse me pipe Ock and then single quotes and then scrolling brackets again print dollar sign and F and scrolling brackets and single quotes and parentheses. Okay. All right. So let's go over what we've done so far. If the choice is quit, then we're going to quit else we're going to take the choice and we're going to we're going to use Ock to pull out the third op third space in our option, which is 123. And we're going to print that and we're going to pipe it into our browser. So dollar sign browser. Okay. And then we want to go question quotation marks dollar sign CFG, which is this variable right here. Okay. And then we need to end it. We need to end the if statement. So else, okay, echo program terminated, oops, and then and and exit one, and then fi. Okay. Now, as we are right now, this should work, but we want to make sure that there's a space afterwards that may always make sure there's a space at the end of your batch script. Just in case sometimes it needs it, sometimes it doesn't. Okay. So we're going to save this. And we're going to zoom in here again, and we're going to seeding it back to that folder. And we're going to do dot, see if this works dot slash BM.sh. Now we should get a D menu thing up along the top with our list of bookmarks. And we do now I should be able to select one of these. This will just choose Facebook. And we'll see if that actually worked. And it did. We'll see it because it's on another monitor, but it can actually see it opened up Facebook. Okay. So now that's how you do it with D menu. Now, if you want to do this with Rofi, it's very simple. I mean, it's literally just changing one word. So what you want to do is get it back in there in some mode here do Rofi, and then added a dash in front of D menu, and then save it. And then what we want to do is just open this up and do go back into my folder do dot slash. And then we get it with Rofi see, and then we just do go to, I don't know, Unix porn here. And we have Unix porn. That's how you do it. That's very simple. And like I said, the vast majority of this was actually just completely ripped off from district tube. So thanks DT for providing all the work. All of his scripts did more complicated things, but this is just going through and creating a list of bookmarks that allow you to, you know, access them wherever you would with whatever browser you want. All you have to do is change the browser that you use. Now, if you have a XDG browser variable set environmental variable set, you should be able to change this to change this to dollar sign browser. And that should still work. I don't have an XDG browser set because I like multiple browsers that I use. I just would rather have this explicitly set to Firefox. Okay, so that's just a very simple script that you can use to manage your bookmarks and independently of your browser. And it's something that you created. So it's really, you know, you can feel a sense of accomplishment, you know, that's what that's the reason why I guess I do it. So because I actually, after Buku stopped working, I went through and decided just to use, you know, the built-in Firefox browser bookmarks thing. But I think I'm going to feel better now that I'm going to have, you know, this script that I can just use. Now, actually, I should show you one more thing. If once you've saved this, you'll want to copy copy it into so pseudo CP slash user local bin. And I actually want to make sure you tell what bm.sh into into users local user USR local bin. That way it's in your path. If we do this, I can be anywhere in the system and do bm.sh, and it will work because it's now in my path and it will tell me where, you know, it'll just do it. I don't have to go through dot slash or whatever. And this way I can go through and add this right to S X H K D or put it in my I three configure whatever and assign a key binding to it and it will work. And you know, then I can just, you know, go through and, you know, do my own thing with the bookmarks. So I hope you liked this video. If you did, give it a thumbs up. Make sure you subscribe. You can follow us on Twitter at twitter.com slash the Linux cast Facebook.com slash Linux cast. You can also support us on Patreon at patreon.com slash Linux cast. And I'd like to take a moment to thank our patrons, Devon Marcus America. Thanks for your support. Thanks everybody for watching. I'll see you next time.