 Okay, up here on my screen, I have my terminal on my left and on my right, my file manager. They're both in the same directory. You can see I can list out, this is the directory where I have all these animated GIFs or GIFs that I created on my phone and it's synced over to my next cloud server. Anyway, what I want to do is be able to send files to my machine, and this is one way I do it. I have a KS command, which is an alias for a script I wrote called KDE Send, and it's going to use KDE Connect. If you're unfamiliar with KDE Connect, I really should do a whole series of videos on this. It's a free open source program that runs on your desktop slash laptop and also on your mobile devices and allows them to interact, doesn't just do file sharing, you can do remote control stuff, you can run commands, you can share clipboards and messages. When I get a notification on my phone, it's also displayed on my desktop. It's a very useful program. It should be in your repositories and it's available again for Android devices. I'm not sure about iOS, but who cares? So let's say I want to send one of these images over to my phone. What I can do here, I just type in KS and I hit enter and it will list every file in this directory and subdirectories, although there is no sub directory in a particular folder. I can type in, start typing the name of the file, it's using FCF to filter through those files, and when I hit enter, it sends it to my phone. Another option is, if I give it a file name so I can say KS, again that's just an alias for my script which is called KDE Send, I can drag over a file, hit enter, and now that file is sent to my phone. These are small files, they go pretty quick, but you can transfer any files, even video files. You'll see a little dialogue. You might pop up on my screen here real quick, since these are small, but if I was transferring a larger file, you'll see a progress bar as it's transferring both on the desktop and on my phone. So that's great. So let's look at how this works. So let's go ahead and make this full screen, make it a little bigger, and I'm going to cat out my script, which is a user, local bin, and I call it KDS-Send. And I'll put this on paste bin and link to it in the description of this video. Okay, so this first line here is creating a variable called devfile, it's short for device file. So real quick, let me run kd-commandline, so kd-cli-l. This will list all devices that are available for KDE Connect that I have set up. And you can see I have three set up. This one's my old phone. This one's my tablet. And this is my current phone. You can see that these ones are reachable, but the only one I have paired is this one right now. So this is what I want. When I'm sending a file to my device, the command I would run is kd-connect-cl and then dash d for device, and I've got to give it the device ID. And then I do dash dash share and give it a file name. So I will just say savannah, just trying to find a file there. And I will hit enter. That is actually the command that's running, but my script is a little bit more so you don't have to type all that at times. So again, let me cat out my script. The first file is just a text file that I created. I put all my custom scripts, my own scripts in a folder, hidden folder in my home directory called .fbk, filmed by Chris. And for SMS stuff, I have this. And this is just, if I cat it out, is a text file with whatever I want my default kd-connect device to be. And that's its ID. So that's what this first line is doing, is it's just checking that file. Well, it's creating a variable for that file, but then we want to check the device ID and that. So what's this next line? This is saying, okay, if this file exists. Okay, so maybe I'm copying my script to a new machine and that file doesn't exist. I want to be able to create it. And I don't want to have to open up Vim and I don't have to want to go and get the device ID, open up Vim and paste it in there. So what I do is here is after I say, this is the file I want to check, does that file exist? Okay, if not, then run the kd-connect command with list to list all devices. So again, if I take this part of the line and I paste it here and hit enter, nothing's going to happen. Or I guess it did list out the devices. Oh, because that variable doesn't exist. Let me create this variable in my shell here. Now let me take this and run this and nothing should happen, right? Because that file exists. But let me go ahead and just remove that file. Now, if I run this command, now it's going to go, oh, that file doesn't exist. Run kd-connect, list all devices. Great, so it lists all devices. Helps me a little bit. Let me go back and cat out this, oops, wrong file, cat out this. Next part of that command. So I'm going to list them and I'm going to pipe them into FZF, which I've talked about a lot on my channel. It's a great program for just searching through whatever input you give it. In this case, it's going to be a list of devices. So checking if that file exists, the file doesn't exist. Run the command to get a list of them and pipe it into FZF and I can choose one of those files. The next part here is just cutting it and awking it to get just that. So if I run all of this and I hit enter, it lists all devices and when I choose one, it's going to give me just that device ID and it's going to dump it into our file. So if I copy my script to a new machine, great. So let's go ahead and run this whole thing like this. I'll select my device, my phone here, and it just debunked. It just dumped that device ID into that file. So now my script can continue. What's going to do here is going to grab the first line of that file, which is going to be the device ID. It's probably a better way of doing this, like creating a variable in that file and then sourcing it, but this works fine for this script. So basically, again, it's just going to, after making sure that file exists, if not create it, dump the ID into it. Now we're going to get that ID. Next thing, okay, so now we have our device all set up. We're going to get input from the user, the first argument and we're going to set that to a variable called file. Here we're going to check, was anything inputted? Did I give it a file name? If not, we'll then replace that variable with whatever file I select from FCF. So that will, again, if I drag and drop or type out the name of a file, great, it will continue. If not, it's going to FCF and I can choose a file. Then it's going to check again, did I actually choose a file with FCF? If not, just exit, we're done, okay? Otherwise, send it to the device, right? So again, my command is called KDE-send. This is what I named it on my machine, but I alias it so I can just type KS. And then I can also call this from other, so I have three options or really two options, but I can, again, give it a file name. Boom, that just got sent to my phone. If I don't give it a file name, I can choose a file and send it. And of course, since I can pass arguments to it like we did in the first example, if I want, I can just KS and grab any one of these and send it to my phone. So that is how I transfer files from my desktop computer to my phone. Quick and easy, thanks for watching. Filmsbychrist.com, again, I'll put the script up on Pay Spin if I haven't already and I'll try to remember a link to it in the description of this video. I hope you found that useful and I hope that you have a great day.