I'm doing this just for the sake of doing it. One place to find the "Latest" solution on this issue. Unburying it so I can find it easily, and easily get results from people who may want to do some experimenting of their own.
MULTI-WORKSPACE CONKY!
A Preface: This is a bit of code I developed, inspired by someone's question about Compiz. I don't use it myself, but I did get a buzz out of the inspiration and it has become a, relatively untested, possible future way to solve the "I don't have enough room for all the data I want in Conky" problem many of us have.
To be clear, this is a way to get Conky to display different data, or display differently, on different workspaces in Linux. It has not been fully tested for every window manager, but I know it works in XFCE4.
There are two methods currently known: Compiz and Standard. I will describe the standard, and show the code for it. Then, I will do Compiz as a special case. When push comes to shove, they're the same.
Standard Method: 4 Workspaces as example.
In Conky there are three Objects that look at your workspace. ${desktop}, ${desktop_name}, and ${desktop_number}, which may be variations on the same thing. It really depends on your window manager. Gnome, KDE, XFCE4, Enlightenment, and yes Compiz, all call a workspace a specific thing in the code. Note: I will eventually update the specific requirement for each of these when, one day, someone with each of those window managers eventually tests the code and tells me what works. For now, I will use ${desktop} as the standard term. When you, the reader, go to try this it may be different for you.
Currently known:
XFCE4 = ${desktop}
Compiz = Special Case, explained below.
Gnome,Fluxbox = ${desktop}==, Gnome and Fluxbox both, when tested, spit out errors if only one = is used. In fact, the double equal is pretty standard.
KDE = Unknown
Enlightenment = Unknown
Other = Unknown
The goal here is to make Conky decide what workspace is currently being shown, and change how it looks accordingly. So, you are going to want to know how to use an ${if_match} statement. Which is really very simple. When I get to the example of how to decide what workspace, it will be formatted like so:
Code:
${if_match (Condition)}
<Do Something>
${else}
<Do Something Else>
${endif}
It is important to note three things for if_match statements. One is that the (Condition) won't be in brackets, it will be a conky object, probably something that changes. It will compare what it has changed to, so it will have an equal/greater than/less than/etc. statement after the Conky Object. Two is that <Do Something/Else>, much like the (Condition), only means you're going to put all of the code you want in use in place of <Do Something/Else> and not that you need the greater than or less than signs. It's just a place holder. And finally that you can have as many if_match statements as you want, nested inside eachother depending on what you're trying to compare, as long as you put an equal number of ${endif} objects at the very end of the structure. And you'll see that in the workspaces example code. And now that you understand the Conky object to compare the workspace, and the if_match structure, you can make the two work together to see what Conky should display based on your workspace.
Which is this: How to compare your workspace to display specific items in Conky.
Code:
${if_match ${desktop}=1}
<Insert All Code You Wish On Desktop 1, As You Want It.>
${else}${if_match ${desktop}=2}
<Insert All Code You Wish On Desktop 2, As You Want It, If you don't want anything, leave this empty.>
${else}${if_match ${desktop}=3}
<Insert All Code You Wish On Desktop 3, As You Want It, If you don't want anything, leave this empty.>
${else}${if_match ${desktop}=4}
<Insert All Code You Wish On Desktop 4, As You Want It, If you don't want anything, leave this empty.>
${else}
${endif}${endif}${endif}${endif}
Simple, isn't it? Here's where it isn't. You need to write an entire Conky for each of those desktops. Or, at the very minimum, everything that goes under the TEXT object. This will make it a very long text file, and you may want to make a comment (# at the start of a line to Comment in Conky) to give you a visual cue as to which section is for what workspace. Also, as time goes on and I get the chance to get some test results in, the ${desktop} variable may have to be replaced with one of the other two variables (${desktop_name} or ${desktop_number}) in order for the structure to work for you. In the case of ${desktop_name} it will be replaced with the title or name of that workspace in quotes. Example:
Code:
${desktop_name}="main"}
When you don't want Conky to display on a particular desktop/workspace, then simply leave the if_match statement in place, and leave the <Everything You Want> part empty. Empty, as in without that comment.
There will be consequences to this. As testing goes on, there may be certain window managers that display the outline of Conky, but leave it blank when you have no data inside. This will be due to the minimum_size environment variable being the same across all desktops/workspaces. If/when we discover a way around this, making Conky smarter, I will inform you how here.
Compiz: The special case, and why it was the inspiration.
Compiz is special. So many Linux users know this. It's all pretty and cool and stuff. It's 3D and makes that cube thingy that spins, and all that transparency and... okay I don't use Compiz at all. I don't particularly like it. But I did find something out about it when a user (jwcalla, whose problem is the inspiration, thus deserves credit.) came to this thread with a problem. Using Compiz, how do you get the different desktop/workspace areas to display different data? So, in fact Compiz is the first case we had to try any of this code, and has yet another reason to call it "Special", in this case being that it was the original.
And then we discovered something in the troubleshooting. When he ran a command (wmctrl) to show how the desktop was being displayed, we were all shown something very unique about the Compiz window manager. It doesn't have workspaces or desktops. It has one desktop image, which it gets by taking the number of workspaces you want, and multiplying that by the horizontal resolution you picked for the monitor. So, instead of 4 workspaces, each, say, 1920x1080, it was one giant workspace that was 7680x1080. And then it takes that, and wraps it around a 3D object (the Cube you see in so many screenshots) like a tiled mural. This is why Compiz calls them Viewports. It's just one narrow view of the mural.
So, how do you make Conky choose from that? Well, each pseudo-workspace, AKA each side of the cube, AKA Viewport, actually exists at a certain X co-ordinate on the tiled mural. "Huh?" Yeah, I know. But wmctrl (you should probably have it on your system, but I can't guarantee it.) has a display readout in a command prompt. When run using Compiz, the X and Y co-ordinate is shown. I don't have the program myself, but to run the general readout, you type this in a terminal:
This is important, because this gives us something that has data in the command prompt to Compare to. To get that data, we're going to, and this is my favourite way to say it, grep/awk/sed the hell out of it to narrow down only that spot where we care about the number. So, we need this command for Conky. And you'll see it again in the example:
Code:
wmctrl -d | grep 'VP:' | awk '{print $2}' | sed 's/,0//'
Quick explanation: the | tells the command prompt "before you report what that did, do this." The grep is a search program for command line interfaces that takes what a program spits out, and looks through it for a search string. awk is a program that reports back a specific result from something you tell it. sed is stream editor, which takes everything you've been asking the command line and edits or formats it into something you want.
In this case, what this command call is doing is as follows:
wmctrl: desktop report, search for something called 'VP:', report back the second thing you find after you've found 'VP:', take that thing and delete everything that looks like ',0', because I don't need it for what I'm doing.
Guess what. You just reduced about 5 lines of data about your desktop as it currently is in Compiz, including it's current horizontal position on the big mural, down to just a single number for you to compare. Huzzah! You just located the number that represents the Viewport you're on!
How is this useful: It's a number. You can compare to it. if_match likes that. And using the ${execi} object, you can tell Conky to do this.
Getting To The Point!
For every viewport you have, it will have a number. Multiply that number by your Monitor's horizontal resolution (in this example, 1920 of 1920x1080) and that will be the number you compare the statement to in Conky. Also in this example, the ${execi} object, which means execute this command, at this interval, is being run every 60 seconds. Yes, this will mean, it quite possibly could take a delay of a few seconds for Conky to know you're on a different Viewport.
Here's the desktop comparison for Compiz:
Code:
${if_match ${execi 60 wmctrl -d | grep 'VP:' | awk '{print $2}' | sed 's/,0//'} == 1920}
(Insert All Code Below The TEXT section that you want on the first viewport.)
${else}${if_match ${execi 60 wmctrl -d | grep 'VP:' | awk '{print $2}' | sed 's/,0//'} == 3840}
(Insert All Code Below The TEXT section that you want on the second viewport.)
${else}${if_match ${execi 60 wmctrl -d | grep 'VP:' | awk '{print $2}' | sed 's/,0//'} == 5760}
(Insert All Code Below The TEXT section that you want on the third viewport.)
${else}${if_match ${execi 60 wmctrl -d | grep 'VP:' | awk '{print $2}' | sed 's/,0//'} == 7680}
(Insert All Code Below The TEXT section that you want on the fourth viewport.)
${else}Out Of Viewports (Or copy/paste more of these.)${endif}${endif}${endif}${endif}
As with the standard version, make as many if_match statements as you have viewports, as long as you have the same number of ${endif} objects.
That is the current state of the multi-workspace code as I have it. I am very much looking for people to test it and get back to me on what they may have had to do to get it to work on their window manager.
Bookmarks