 We're going to welcome back to another video for my YouTube channel over here in which I'm going to discuss basically a project I'm working on at the moment for basically automating stuff on the Linux desktop using the very nice xDewtool command line interface and it is a little bit intimidating but certainly what it can achieve is quite powerful and I'm quite excited about so this firstly is Linux 1910 which is not an LTS release it's a rolling release but these utilities at will not be installed I'm not sure if xDewtool is actually in the repositories or sorry if it automatically comes on systems either but in any event they are both definitely in the repos so those two CLIs that I'm using here for this this quick video are at AT and xDewtool and for those that are not familiar with at basically it's a it's like a one-time cron job kind of a setup so basically you know cron jobs if you open up your crontab on your system it has you know jobs that are supposed to run on a recurrent schedule so whether that's you know every second every day every month every year such and such a command but that would occur every single day and AT basically is a once-off event scheduler so you can just schedule one-time event so that's what I'm hoping to do here I have tested the script and it is running relatively nicely but you can also you know and I've set the AT that this command is going to run at a certain time tonight basically so what this does really I'm just going to call up the script in Kater in my VM or in my IDE rather so firstly you know I'm relatively new to batch scripting and by no means an expert at this at all in fact a rookie but I am just kind of playing around and this is a quite a cool project that I think I think demonstrates well the potential for x-do tool what it can do and I'm making this video actually because I saw that the x-do tool tutorials on YouTube while they're excellent and there's a lot more to dive into I couldn't really understand the practical practical points of it so maybe this video will explain that a little bit better so basically this is something that I'm going to be running off my laptop my laptop is like an old Linux laptop that is just connected to a white screen television the first so the first thing I've done in this script is just make sure that the outputs are correct so there's another good tool I recommend in Linux called a render and that's kind of it's a very lightweight display manager so these are my three displays I have in front of me right now the nice thing that you can do is once you have your displays as you want them you can then save the layout and it will give you a it'll give you a by script so I've just called that by script and you can inspect it and you can see it's just kind of a couple of lines calling it's basically just a front end a render is a front end for x render and x render calls you know dvd the dvd output is primary this is its resolution this is its position its rotation is normal and the position actually organizes the so the if I go back to my screen layout here it goes hdmi to dvd dvi and then hdmi one so it's setting hdmi 000 then the dvi comes next it's 1920 pixels across working from left to right and hdmi one is 100 1920 times two from the far left so that 1920 times two and they're all 1920 by 1080 resolution displays so it has the order there as well so that little command that you're calling that by script which is really just one big command basically sets me up so that even this is actually have set this up as a startup script on the laptop this is just so in case it's not running in that configuration and the laptop is has its screen turned on and the reason for this is because you need a bit more fancy commands than I have actually put in to really do xdo to it properly you should ideally you know refer to a window id and to a screen I've just kind of adopted a bit of a quick and dirty approach but this should work if the if the if there's only one screen as my thing is configured go up to the quick things of muting volume and then setting it to 100 percent so this is toggling ALSA mixer firstly unmuting it so if it's muted this will unmute it I think that might actually be should be toggled there's this can be a little bit buggy if it's muted or muted then setting it up to 100 percent so it's I'd basically be setting the volume on the actual TV and not on the OS the OS we delivering it's 100 volume now so I'm watching this show on Netflix called diesel and this basically says you know this Google Chrome is very simple if you're not if you're not doing any variables so there are this I'm not sure if there's even a man page but there is a man page you can tack on incognito to get in incognito motor and in a new window or you can even actually open it in a specific profile but if you just do Google Chrome followed by the URL it'll just basically open this in Chrome so if I just bring this guy back over to my screen here if I just run that it's just opens the diesel in a different window here sorry into the into the chrome I had open so now so far so good but the problem is if we just copy this into a browser this it'll just arrive at this page and that obviously will not start playing now if you haven't started watching a Netflix show yes and you might get lucky like if I click on to Tiger King for example Tiger King is the same thing actually if I click onto this if you haven't if you haven't watched something before I'm just trying to get this to work it might actually start playing but basically you want to go like this and see what see what happens when you get to the show you want to watch now I'm just this is again for the purpose of automating it now how do you get the script to automatically click on this button so I'll just show you what else I've done in my script using xdo tool you basically so I wait five seconds after this opens sleep five that's the number of seconds and that just basically pause the things for five seconds so any kind of banner advertisements or javascript elements can kind of display themselves and because it's all relying on this coordinate here xdo tool move mouse to x and to y this this is in pixels and then click immediately on that part of the screen so I'll show you how I found that we just find the command quickly xdo tool find current mouse position it's not particularly hard to find it's the first stack overflow result for that I'm just going to copy this into my terminal here so it is xdo tool get mouse location minus minus shell tack tack shell so what I did was I basically just move my mouse here and I literally now my mouse I'm going to go nice and centered on the button here I have my right hand off my mouse and my left hand hovering on the enter button I click to enter and you can see what it's come up with here is the x coordinate the y coordinate and the screen and it's also giving me the window idea and as I said if you're doing this property you will that's really the the more elegant way to do it you should certainly also refer to the screen but again because I'm on one one screen on this I'm just doing this kind of a little bit quick and dirty so uh 155 and 47 now one thing to say is you want to check your zoom here so I'm I was zoomed at 100% let me just do this one more time 204 because I move slightly um let's get nice and centered again let's let's let's take these coordinates 131 and 484 and let's just over 131 and 484 131 484 very close to what was in the script um so basically it's going to move for me onto that screen position and then it's going to click so this will take us this far uh then I told it to wait for five more seconds and now I wanted to click on the uh on this guy over here so I repeated the process I this is a full screen button um um and I basically uh this did not work when I just tested it so I'm not expecting a miracle to happen then to work again although we are we are watching schtiesel um the idea was for the mouse to come over here and click on um click on basically the um the button and then to make that into full screen that it did get over the button on my test for some reason I didn't uh click xdo tool um there is another way I'm just thinking on my feet now um that I could basically because f11 will also put this into full screen mode uh so if I could tell it to uh hit uh f11 that would also work so I'm just gonna actually add this into the script and you never know this might be this is my first time trying a simulated keystroke an xdo tool is very powerful it can do both mouse and you can see this is click one is uh is left click I believe click two is a right click click three is a context click um so it can do everything in terms of automating your uh simulating keystrokes and mouse movements and even dragging and dropping stuff so it's very powerful as I said I'm just really scratching the surface of by scripting and this the cli itself but it did work so let me just give a shot let's try to um xdo tool key f11 and then let's end the script so that should be entering f11 and f11 will um make should make it full screen so without any further ado I'm going to move this over here and I'm going to get out of here and I'm going to show you how this works now I've added this to my get to a github project you can follow me on github my username is danielrosiljlm and uh yeah just as I learned I'm just posting these basically now in order for this to work I just need to make sure I'm not in any other chrome windows on my other screen so I've only got one chrome open and let us let us try just navigating of course you need to give it the right executable make your back script executable executable and then as I said I'd be using as now um plus whatever you know 2130 today or april april 12 and then basically saying just run the script at that time one thing I did do in my initial script was I actually added that as well um you know uh basically adding an at command saying to turn off the computer so that's another cool thing you can do is you can have this get the script running from at and then have an at command in the script itself in order to turn off your machine after I don't know two or three episodes what that would be probably uh 200 minutes or whatever uh you can work it out so let's give the script a go there we go so far so good it's open steezel now the mouse in five seconds should move and it's clicked resume perfect now we are watching it and there we go it's either I can't tell if it hit f11 it did hit f11 because the little dialogue windows come up and we now have steezel running in um I'm gonna actually not show too much of this because I'm worried that the copyright uh copyright automated detection stuff on youtube is gonna is going to accuse me of uh of uh trying to trying to cast uh steezel which obviously is not my intention at all so that was successful so that basically that's little script I built uh would be enough to uh you basically you know you can just set that as an at command um leave your laptop open uh at nine o'clock now in terms of what I would like to do with this you know I might want to be um you know perhaps there is if you're emceeing an event and you'd want to put up a video at a certain time and you want everything to run like clockwork uh you could just have the laptop open have it connected to a projector and you know and just so long as the power configuration is not you don't have like you know automatic screen blackout and automatic power off uh that tends to screw up projects like this but so long as you have all those correct um that this would work you know completely you know you could open up a video stream a video uh you might even need to use xdo2 but that was the point to this video and you know close the window or whatever else you want to do uh I could have made the script a lot more elaborate but uh so that was it basically just a little bash script uh putting that put to the tv getting the audio right opening up my series on Netflix waiting for five seconds micing over to the resume button and again make sure you're capturing these coordinates when your screen's a hundred percent and it could change based upon the series you're looking at or the UI of Netflix it might the UI might change and these could be so you might need to recalibrate uh clicking and I could have added might have made um QAing a bit easier if I've added if I'd added a smaller pause here then clicking then another five seconds and then moving over to the full screen button here clicking on clicking on that um and uh I just I added both clicking on the full screen button um and f11 because I wasn't sure that didn't work the first time so the end the f11 worked and I could again say keep that running for a certain amount of time and then finish it so that's it I hope this little tutorials tutorials is a wrong word I keep using it but this little demo of what you can do with xdo tool in the real world because as I said some of the videos will show much more elaborate things where you know they were like creating blank files that kind of wanted to show what you can actually do for you know practical applications of this very cool automation tool for the Linux desktop thank you for watching and any queries do not hesitate to reach out that's my website and there's a contact form there danielrosilrosil with 2ls.co.l and uh have a great day