 One of my favorite tiling window managers is the Qtile tiling window manager. It is a very nice tiling window manager It is written and configured entirely in Python It is basically an Xmonet clone just rewritten in Python rather than Haskell and one of the really great things about Qtile Is it comes with a built-in panel that is very fully featured. It has a million built-in widgets So let me show you something that I've found today that I didn't know existed So I was checking out the built-in widgets for Qtile if you do a Google search or a DuckDuckGo search for Qtile built-in widgets you'll get this page and it lists all of the widgets Here in the left hand column that are available for your panel and by the panel I'm talking about the panel and Qtile. So everything on this panel is one of those widgets on that page And while I was reviewing that page. I noticed that every single widget on this page It has available keys that you can use as far as setting margin and padding background color foreground color Font and things like that and I noticed this right here. I don't know if you guys can see that Let me see if I can zoom in a little bit every widget has this key here mouse callbacks What is that? Well, that is a dictionary of mouse button press callback functions Basically, you can set functions that when you press a button on the mouse on that widget It runs that function. So for example button one on the mouse is your typical, you know, left-click button and We can write a function. So when I for example left-click on my Bitcoin ticker here, you know It actually runs some kind of function. We're gonna have to write a function for it But that's pretty neat. I actually did not know that the Qtile widgets had these mouse callbacks I don't think they've been around that long. See, I've been a Qtile user for many years Seven or eight years probably and of course Qtile, you know keeps being developed They keep adding new features and my configs date back so many years, you know I don't often go to the documentation and look at some of the new features They're adding so when I saw this mouse callback functionality I was kind of blown away because I immediately started thinking about all the cool things that I can do by being able to click On all my widgets and that's exactly what I think I'm gonna do I'm gonna go ahead and pull up my config and I'm gonna start adding some cool mouse callback functions So the first thing I'm gonna do is I'm gonna open up my Qtile config So let me launch that and I'm gonna go ahead and launch this in VM I'm gonna zoom in a little bit and in my config if I do a search for all caps widgets I have a section here this commented section here called widgets and of course, this is my panel It's basically a widget list for everything that is in my panel Everything you see as far as group box, which is the list of windows the run prompt Which is a D menu prompt. You won't see it since I'm not running D menu at the moment window name Of course is the name of the window with focus right now It's the alacrity terminal and then you see I have my Bitcoin ticker. I have a thermal sensor for CPU temp I have Pac-Man updates and various text box widgets Which are just these unicode arrows that give me this power line effect pretty straightforward actually if you take a look at My config you should be able to figure out very easily how these this whole widget system works You see I define a widget and then I have a list of keys that I define such as font size margin padding border width Etc. You can get the keys for each widget on the built-in widgets page every widget in the documentation We'll list all the available keys for you and one of the things I think I'm going to do is I would like on my panel I want some kind of start menu button I want some kind of icon or image that I can press that brings up a menu system of some kind even though It's a tiling window manager. I'm gonna start making this more desktop environment like I want some kind of Menu button that when I press it something comes up even if it's just the menu or Roe fee, you know Some kind of run command prompt So if I go back to the built-in widgets and look for widgets that I could use I notice there is this image widget. It is called widget dot image the capital I in image So that's what I'm gonna do. I notice it does support mouse callback events too. So let's start there So I'm gonna go back here and let's add one of these image widgets So in VM I'm gonna hit o on the keyboard to start a new line here and I'm gonna add widget dot Image and then opening parentheses. I'm gonna space down a little bit I'm gonna go ahead and add the closing parentheses and a comma just because I know if I don't go ahead and add that I may forget it later. It's gonna cause me some problems and then for the keys the available keys I know for sure I need a file name because we need the file name of the image That's going to be the image widget and then I know I'm gonna use the mouse callbacks keys as well I don't know if I will use any of the other ones. I may Let's go back and I'm gonna go ahead and add file name space equals and then in quotes I need the location to the file name and I noticed the documentation did say that the tilde character Was okay to use in the file name. So the little squiggly tilde character That's your alias for your home directory and I know I have got a Directory on my system at dot config slash q-tiles slash icons and that's where I keep icons for the various layouts But I also have an icon in there called python dot PING So let me go ahead and just add that and that will be our start menu button And then at the end of that line very important Do not forget the comma if you forget the comma it will error out on you and then after that Let's add the new line and mouse underscore callbacks space equals space and then how do we do mouse callbacks? I'm gonna have to review the documentation here mouse callbacks looks like we need to do these inside the curly braces so let me go back and I'm gonna do an opening and closing curly brace and Then if I look deeper into the documentation I did notice that I found this page here for basically your widget base fall And I noticed it does give me an example of exactly what to do with a mouse callback event Needs to be in the curly braces and then in single quotes the button on the mouse We're using and then a colon and then the name of whatever function we're writing Let me get back over here. So if we do this exactly the way it's suggested We need single quotes and inside single quotes. I'm gonna do button one because that's the left-click button on the mouse That's the one I want to do this for and then what do we want this image widget to do? Well, I want it to run some function I'm gonna call it open D menu because I think that's a simple function to write and I don't need a Comment at the end of this because that was the last key that we're adding So I think we're good there. The only thing is we need to actually write a function now So let me go up here. I'm gonna create some space and I'm gonna create a new section here And I'm gonna comment mouse callbacks Let's just create a new section here in the config and then what I'm gonna do is let I'm gonna go ahead and write a Simple function. So let's go ahead and define Open D menu and then in parentheses q-tile And then this is very important at the end of this line We need a colon and then let's go ahead and hit enter and then make sure you are spaced over about four spaces here in Vium it automatically spaces me over it knows exactly what needs to go on here and then q-tile dot cmd underscore spawn so this is a q-tile command to spawn something What do we want to spawn well in parentheses and in single quotes? We want to spawn this command D menu underscore run That is your command line way of launching D menu now if the punctuation and everything is correct I could colon W to write this in Vium and then super shift R to restart q-tile And we didn't get any errors and my python dot ping image is Loading right here and let's see if D menu runs when I click on it with the mouse D menu runs when I click on it with the mouse How cool is that escape and D menu goes away click on it D menu launches and of course I could get much more creative with that mouse callback So if I go down to where I have my memory widget You see I have memory and how much memory is in use versus my total memory So I have 64 gigs of RAM and I'm using about 3.3 gigs and what I'm going to do is I'm going to call a mouse callback function here and I created this function open H top and if I scroll back up I've already created the function here open H top. What is it going to do? It's going to spawn the alacrity terminal and launch H top inside alacrity So let me go ahead and write and restart and if I didn't create any kind of errors here Okay, it restarted just fine. So now when I click on the memory widget It launches H top for me that way if there's any memory problems You know, I just click on the memory widget H top opens up and I can see what is sucking up You know all of that RAM I'm going to go ahead and create a mouse callback for my volume because that's another one that I Suspect I will need something for along the way. I'm going to create a new function for it I'm going to call it open PAHVU because I think what I want to do is click on the volume and then it opens PAHVU control and I've already created the function I've defined open underscore PAHVU to run Qtile command spawn PAHVU control. So let me write Restart and if there's no errors restarts just fine. And now when I click on volume When I click on volume, it's muting and unmuting. So I had already had something set up for volume Yeah, I think that the problem with the volume widget is it already has mouse functionality built in by default the left mouse button Mutes and un-mutes and then the scroll wheel can lower the volume and raise the volume if you do the scroll wheel So I probably will scrap that idea of using mouse callbacks with the volume widget because it's already got a lot going on What I may do instead is do something for my Pac-Man updates widget. So let me find the widget for Pac-Man here it is and Go ahead and paste a mouse callback and I'm going to do Instead of open PAHVU control I'm going to do open Pac-Man and escape and let me get back up to where I was defining those functions since I didn't use Open PAHVU I'm going to rename this to open Pac-Man and what I want this to do I want this to launch our terminal. So I'm going to run a LACRETY dash E And then I wanted to run this command sudo Pac-Man dash capital S lowercase y lowercase u escape Let's right. Let's restart QTAL and if all of that worked correctly now when I click on my Pac-Man updates widget Which I don't know if I have any updates. Let's click on it and see I notice clicking on my updates widget is actually not doing anything There it goes. I don't know why it didn't work at first But now you know what I think I think it took a few seconds for the widget to actually run whatever it runs to figure out How many updates are available and once the widget actually ran and displayed the number of updates now clicking on it actually launches these terminals And these terminals of course are asking me for my sudo password because it opened a LACRETY and it's trying to run sudo Pac-Man dash S-Y-U and if I entered my password it actually does run sudo Pac-Man S-Y-U And if I declined to take this update right now because it looks like it'll take a while The terminal closes immediately Because it's one of these weird situations where you know when you're trying to run Launching a terminal and then launching a command-lined application from the terminal it closes immediately Once it's done or once you cancel it Well, I think that's all I'm going to do with these mouse callback functions for right now I'm gonna go ahead and push my config to my GitLab for those of you that want to examine my config to see How exactly you need to go about adding these mouse callbacks to your widgets, but I think it's really neat I'm actually kind of impressed for you know just spending a few minutes on this I kind of like the Python logo and the fact that when I click on it, you know, I get a D menu It actually launched D menu on the wrong screen that time. Let me make sure I have focus on the right monitor Yeah, you guys see at that time That's pretty cool And of course instead of the menu I could have it launch Rofi or you launcher or Synapse or or anything you want But I just thought that was really neat because I know a lot of especially newer Totaling window manager users kind of miss having a button they can click on and access some information I just think that's kind of neat to have in my config. All right before I go I need to thank a few special people I need to thank Michael Gabe, Heplew, Nate, Corbinian, Mitchell, Entropy UK, Arch5530, Chris, Chuck, DJ, Donnie, Dylan, George, Omri, Paul, Sean, Tobias, and Willie these guys They are the producers of the show without these guys You wouldn't know about mouse callbacks on these panel widgets in Qtah. You wouldn't know about it Also, I need to thank each and every one of these ladies and gentlemen all these names you're seeing on the screen right now This is all my supporters over on patreon because this channel is supported by you guys the community No corporate sponsors here at distro tube. If you'd like to support the channel search for distro tube over on patreon All right guys Peace