 Okay, today we're going to be taking screenshots. There's a lot of great programs out there for taking screenshots on Linux that have lots of features, but I just want something simple. I want to be able to select a section of the window, have that saved to a directory by default, and also give me the option to send that screenshot to my phone because that's something I do commonly. And if you have image magic installed, which is installed on a lot of systems, if not, it's going to be in your repositories on Linux. It's just a very, very common package for manipulating images. And part of that package is a program called import. And if you type import and give it a file name, so I'm in my shell here, I'm in the same folder here, my file manager, if I type in test.png hit enter, you can see it gives me the little crosshairs here, and I can select part of my screen and it automatically saves that as png. If I give it jpeg, it will do the same thing and save it as a jpeg file, whatever extension you give it, and it supports pretty much all your common image formats. Now, be aware that doing this, if you give it a file name, image magic will automatically overwrite the file without asking. So if I run this again, and I select this, you can see that it automatically overrode that file. So that's the import command. That's super simple, but I have a script that does a few more things. So again, I'm going to be able to do one more thing with that same command. If you don't drag, once you get your little crosshairs, if you just click a window, it takes a screenshot of just that window. So there's that, or if I click this window, it's going to take a screenshot of that window. So that's useful if you want just a certain window instead of a section of a window. You can also set it up to take full screenshots. I'm not sure if there's a mouth shortcut for that, but you can give it a command to grab a certain window. But let's go ahead and look at my script here real quick, and I'll walk you through it. Okay, first off, I have a, there's a program. I've talked about this in the past called xdg-open. It's probably on your system if you're running xorg on your desktop, which most Linux users are. What this is going to do is you pass it a file, and it's going to open up that file in whatever default program you have set for. So if it's an image, it's going to open it up in an image viewer, your default image viewer. If you run it with a directory, it's going to open up in your default file manager. And this is useful because that way if you change what image viewer you like as your default, it's going to change here in all your scripts if you use xdg. And I usually alias is on my system, it's alias to open. So I do this in my script here. I alias it to open because maybe using there are other programs, maybe you're not using xdg-open. Instead of changing it everywhere in the script, I just change it here and anywhere you call open it will run that command. So that's why I did that up there. Next, where do we want to save the image? I'm going to save it in my home directory, my next cloud folder under photos. And then I have it here automatically, it's going to save it to a folder for the year because all my images are saved by year and usually month and down so forth. But here it's going to save it to a screenshot thing. So this is whatever year it is when you're running the script, the four-digit year, so it's going to be 2022 in this case, it's going to use that directory. And then we're going to take that directory and we're going to save the screenshot as screenshot underscore and a timestamp up to the second. So as soon as you don't take two screenshots within a second, you're going to create a file. Next, we're going to use the makedir command to make that directory if it does not exist. We're using the dash p option here. What dash p does is basically it's going to allow us to create that directory if it doesn't exist, even if there's multiple subdirectories. If I didn't use the dash p option and I gave it this and the year folder doesn't exist, it's going to crash. So we use dash p, it means create this directory in all subdirectories and don't give me an error if it already exists. So at that point, it's going to continue. Next, we're going to export display just to make sure that I'm using my main display here, because you can have more than one display, especially if you're ssh in, but we want to be able to make sure we're in cryptos. So most cases, that's going to be the default anyway, but I have it set in there. Then we're running our import command with our file, but then after we select an image, we're going to open the directory because I want to open the directory. We're going to open the image in our default image viewer, but then I'm also going to run a little dialogue box that says, do you want to send to our phone? And then if I say yes in that, it's going to use the script I talked about in my last video, KD send to send it to my phone. So let's, let's see this in action. Let me close my file manager here. And I have this aliased or shortcut key to my print screen button. So all I have to do is hit print screen and you can see my cursor has now changed to little crosshairs and I can select the section of the window and it has opened up the file manager. So if I, in another program and I want to drag and drop it, it's ready. I can see it in my image viewer here and then I get this dialogue to honest into my phone. I'm going to click no for this one and it will send it to my phone. Let me go ahead and close those. And now let me hit print screen again. And again, I'm just going to click instead of dragging and clicking and it'll select that whole window. And so I have that whole window and I'll click yes. And it just got sent to my phone. So it's now on my phone in the downloads folder using KDE connect. So that's the, that's what I do to take screenshots. I used to use other programs that give you other features, you know, but 99.9% of the time when I'm taking screenshots, I either want a window or a section of the window and I want to automatically have it sent to my phone in about half the cases. So that's why I added this zenity command to send it there. So that's it. I do thank you for watching. Visit filmsbychrist.com. I'll put this link, a link to this script up on pay spin. And you can get there. So check out the description of the video for that. And as always, I hope that you have a great day.