SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2015-03-01 11:32:44

kbmonkey
#! Die Hard
From: South Africa
Registered: 2011-01-14
Posts: 879
Website

Conky Switcher (Pipe Menu)

Hi Hi. I coded up this pipe menu idea that was rattling in my brain the past week: A menu to switch between conky configurations.

Setup

If you are updating your existing script only do step #1

1. Download the code and make it executable, this overwrites your existing script. (Backup your script if you need to preserve any changes!)

cd ~/bin && wget -N https://raw.githubusercontent.com/woodape/bl-switcher/master/bl-conky-switcher.py && chmod +x bl-conky-switcher.py

2. Place your conky configs into ~/.config/conky, they need to have a ".conkyrc" file extension.

3. Add this entry to openbox menu.xml:

<menu execute="bl-conky-switcher.py" id="conkyswitcher" label="Conky Switcher"/>

(I placed it below "Accessories" to keep things alphabetized)

To load conky at startup and resume with the previous configs you have selected, call from your autostart:

bl-conky-switcher.py resume

Thanks woodape and detinith for the contributions!

Still a work in progress but the core concept is there. Enjoy...

Repository Link: github.com/woodape/bl-switcher

Last edited by kbmonkey (2015-03-18 06:24:20)

Offline

Help fund CrunchBang, donate to the project!

#2 2015-03-01 11:43:17

kbmonkey
#! Die Hard
From: South Africa
Registered: 2011-01-14
Posts: 879
Website

Re: Conky Switcher (Pipe Menu)

On a more technical note, and I would appreciate any help on this, I ran into a problem with setting openbox Execute actions - specifically I wanted to kill-and-restart conky like so:

    <item label="foo">
        <action name="Execute">
            <command>
               killall conky &amp;&amp; conky -c "/home/kbmonkey/.conky/foo/foo.conky"
            </command>
        </action>
    </item>

however this did not work. "killall" by itself works, and "conky -c" by itself also works, but for some reason the two together does not. I then noticed in the openbox menu documentation "ACTIONS are 0 or more actions which are executed in order", so I then tried chaining two actions, but this also did not work:

    <item label="foo">
        <action name="Execute">
            <command>
               killall conky
            </command>
        </action>
        <action name="Execute">
            <command>
               conky -c "/home/kbmonkey/.conky/foo/foo.conky"
            </command>
        </action>
    </item>

I eventually worked around this by calling killall and conky via the python subprocess module (Popen). If anybody could help me do this kill-an-restart conky dance using plain Execute I can remove the entire subprocess dependency and I would sleep better for it.  smile

Offline

#3 2015-03-01 11:55:50

woodape
#! CrunchBanger
From: Cape Town, South Africa
Registered: 2014-03-27
Posts: 113

Re: Conky Switcher (Pipe Menu)

Very cool! For your technical thing, have you tried issuing the command through a shell? Something like:

sh -c "killall conky && conky -c '/home/kbmonkey/.conky/foo/foo.conky'"

Offline

#4 2015-03-01 13:03:59

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: Conky Switcher (Pipe Menu)

Try this:

killall -SIGUSR1 conky -c /home/kbmonkey/.conky/foo/foo.conky

I'm in Windows 10 ATM so I can't check this...

EDIT: No, doesn't work with the `-c` flag hmm

Last edited by Head_on_a_Stick (2015-03-01 13:35:03)

Offline

#5 2015-03-01 17:01:03

PackRat
#! Die Hard
From: USA
Registered: 2011-03-03
Posts: 1,572

Re: Conky Switcher (Pipe Menu)

woodape wrote:

Very cool! For your technical thing, have you tried issuing the command through a shell? Something like:

sh -c "killall conky && conky -c '/home/kbmonkey/.conky/foo/foo.conky'"

This looks familiar; might be what you need. Another option may be to write a script and execute it.

Might want to take a look at the Help:Actions page for openbox .... There are some key binding examples for performing multiple window actions; I would suspect that executing commands in order would have to follow the same sort of syntax.


"It does not require many words to speak the truth." - Chief Joseph, Nez Perce tribe

Offline

#6 2015-03-01 17:24:56

kbmonkey
#! Die Hard
From: South Africa
Registered: 2011-01-14
Posts: 879
Website

Re: Conky Switcher (Pipe Menu)

@woodape, pushing the command through sh -c did not work.

@PackRat, multiple Execute actions do not work for some reason.

Thanks both for the good ideas though. Maybe it has to do with how openbox executes external commands, and using && breaks it.

Offline

#7 2015-03-01 18:55:08

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: Conky Switcher (Pipe Menu)

In menu.xml you chain commands by separating them with a semi-colon. And you need to change eg "&" to "&amp"

Last edited by damo (2015-03-01 18:56:49)


BunsenLabs Group on deviantArt
damo's gallery on deviantArt
Openbox themes
Forum Moderator smile

Offline

#8 2015-03-01 20:14:51

tknomanzr
#! Die Hard
From: Heavener, OK
Registered: 2014-12-09
Posts: 777

Re: Conky Switcher (Pipe Menu)

I use simple shell scripts for this sort of thing. That is all tint2restart and conkywonky are after all.

Offline

#9 2015-03-03 07:37:19

kbmonkey
#! Die Hard
From: South Africa
Registered: 2011-01-14
Posts: 879
Website

Re: Conky Switcher (Pipe Menu)

@damo I tried escaping the text to &amp; without luck, but will try using semi-colons between commands. Cheers!

@tknomanzr, it certainly is. And now there is a graphical menu too! Everybody loves to have choices  ]:D

Offline

#10 2015-03-11 22:59:25

woodape
#! CrunchBanger
From: Cape Town, South Africa
Registered: 2014-03-27
Posts: 113

Re: Conky Switcher (Pipe Menu)

Hey @kbmonkey - @detinith and I have taken your GPL to heart and modified your code a bit more to our liking, and we probably have solved the first todo sufficiently, and put you on the road to the second.

We made it so all *.conky files must be in directories in the ~/.conky folder and the folder is selected in the pipemenu, not the *.conky file. This allows all *.conky files in the selected folder to be launched, not just one, so the script can support multi-conky setups like many people have. The code for that is just replacing the bottom part of your code from the last if statement down with the following:

    if len(sys.argv) == 1:
        CONFIGFILES = list(grabConfigFiles(CONFIGSHOME))
        CONFIGDIRS = []
        for file in CONFIGFILES:
            CONFIGDIRS.append(os.path.dirname(file))
        CONFIGDIRS = list(set(CONFIGDIRS))
        CONFIGDIRS.sort()
        print('<openbox_pipe_menu>')
        for configdir in CONFIGDIRS:
            print(buildConkyMenuItem(configdir))
        print('</openbox_pipe_menu>')
    else:
        configFiles = list(grabConfigFiles(sys.argv[1]))
        subprocess.call(['killall', 'conky'])
        file = open(os.path.join(CONFIGSHOME,'session.log'),"w")
        file.close()
        file = open(os.path.join(CONFIGSHOME,'session.log'),"a")
        for configFile in configFiles:
            subprocess.Popen(['conky','-q','-c', configFile])
            file.write(configFile + "\n")
        file.close()

The file writing bit there stores the full paths of the config files of the selected conky setup in a file called 'session.log' in the ~/.conky folder. This file can then be parsed by a simple bash script called from the Openbox autostart script to launch all the conky configs in this file:

#!/bin/bash
while read config ; do
    conky -q -c "$config" &
    sleep 1s
done < "$HOME/.conky/session.log"
exit 0

I suppose it could be translated into python, but I'm much more fluent in bash and at 6 lines, this is pretty parsimonious.

In any case, I'd just like to reiterate that I'm loving this script you put together. It allows me to have much more organized sets of conkies that I can quickly switch between.  smile

Offline

#11 2015-03-12 10:57:08

kbmonkey
#! Die Hard
From: South Africa
Registered: 2011-01-14
Posts: 879
Website

Re: Conky Switcher (Pipe Menu)

@woodape and @detinith that is a great change, particularly how it supports multiple conky scripts across sessions - thank you! I am eager to try it out later at home  smile

Offline

#12 2015-03-12 21:22:11

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky Switcher (Pipe Menu)

{standing in the corner ... interested ... have to go out ... thinking I'll have comments later}  wink

@ kbmonkey - well done!  Good idea


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#13 2015-03-13 06:32:41

kbmonkey
#! Die Hard
From: South Africa
Registered: 2011-01-14
Posts: 879
Website

Re: Conky Switcher (Pipe Menu)

Your changes work wonderfully @woodape and @detinith thank you. I updated the original post and included the shell script to resume the session from autostart. I was wondering how to support multiple conky's and your idea just seems so elegant and simple  cool

Offline

#14 2015-03-13 12:27:38

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky Switcher (Pipe Menu)

OK, this is cool ... and works well as well.  (Although it doesn't "highlight" the running conky for me in Waldorf)

Here's something...

I changed the directory ~/.conky  to ~/BL-conky as I have a ~/conky-Bl for testing a "zenity" script to start/stop conkys .

GrouchyGaijin - Ununtu Conky Thread - came up with a way to kill individual conkys with pkill vs "kill all":

It chokes on:

pkill -xf "conky -c ~/.conkyrc"

but works well with:

pkill -xf "conky -c $HOME/.conkyrc"

seems it doesn't like " ~ " but does accept the $HOME variable.
and work 100% for conkys on other partitions:

pkill -xf "conky -c /media/5/Conky/S11_MD_Cal-br_2.conky" &

So scripts look like:

#!/bin/bash
## click to start, click to stop
## Original pkill line by: GrouchyGaijin - Ununtu Conky Thread
##    to start stop a specific conky
## This idea by: Stinkeye - Jan 2013 - Ununtu Conky Thread
## start/stop conky with pkill line
## With a tweak by: arclance
## Final tweak by: Sector11 - added wmctrl
## to start a conky on a specific desktop
## remove "sticky" from own_window_hints

## This incarnation created for Bunsen Labs
## Feb 2015

#if pgrep -f "conky -c /path_to/conky/name-of-the.conky"
#then
#	pkill -xf "conky -c /path_to/conky/name-of-the.conky"
#else
#	wmctrl -s 5 && conky -c "/path_to/conky/name-of-the.conky"
#fi

if pgrep -f "conky -c $HOME/conky-BL/bl-right.conky"
then
	pkill -xf "conky -c $HOME/conky-BL/bl-right.conky"
else
	conky -c $HOME/conky-BL/bl-right.conky
fi

EDIT:  NOTE: this part: conky -c $HOME/conky-BL/bl-right.conky must be the same in all three lines.


And in a terminal this works wonderful:

 13 Mar 15 | 09:00:08 ~
    $ pkill -xf "conky -q -c $HOME/conky-BL/bl-right.conky" ; conky -q -c $HOME/conky-BL/bl-right.conky
 
 13 Mar 15 | 09:00:11 ~
    $ 

Neither of these work with [Alt]+[F2] (menu):

terminator -e pkill -xf "conky -q -c $HOME/conky-BL/bl-right.conky" ; conky -q -c $HOME/conky-BL/bl-right.conky
terminator -x pkill -xf "conky -q -c $HOME/conky-BL/bl-right.conky" ; conky -q -c $HOME/conky-BL/bl-right.conky

Now if that could be activated in the python script for the pipemenu you wouldn't need  separate directories for the conkys or one (or more) conky repeated in various directories to get different layouts with multiple conkys.

That would make an awsome pipemenu for BunsenLabs.  I've been using the "zenity" for a few years now and have a few complex layouts & one for different tint2 layouts as well but this pipemenu takes the cake.

EDIT: In action (composite image) - used "Conky Switcher" to open the first conky, then the zenity script to start the next two, leaving the first running.
2015_03_13_09_16_31_1920x1080_Sector11.jpg

Last edited by Sector11 (2015-03-13 12:33:25)


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#15 2015-03-13 13:10:01

kbmonkey
#! Die Hard
From: South Africa
Registered: 2011-01-14
Posts: 879
Website

Re: Conky Switcher (Pipe Menu)

What an interesting idea, thank you Sector11 - adding conky's to the list of running instances for combine layouts? hmmm, I will think on this while I drive home from work...

In the mean time I am imagining adding two menu items, to kill all conky's and another toggle-option that determines if running instances are killed first when a new conky is run.

This way you can click through multiple configs in any order to combine layouts (but would require some extra logic to preserve any session.log entries)

Conky Switcher
--------------> Config 1
                Config 2
                Config 3
                --------
                kill all
                [x] Combine Mode

I will see if I can steal some time this weekend to play around with this idea - will be out of my home-town until Sunday.  O:)

Last edited by kbmonkey (2015-03-13 13:11:42)

Offline

#16 2015-03-13 20:09:07

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky Switcher (Pipe Menu)

You can get a working copy of that at Bunsen-GitHub is you want to see how it works.

But I have to admit I really like your Conky Switcher pipemenu though.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#17 2015-03-13 20:49:06

woodape
#! CrunchBanger
From: Cape Town, South Africa
Registered: 2014-03-27
Posts: 113

Re: Conky Switcher (Pipe Menu)

kbmonkey wrote:

Your changes work wonderfully @woodape and @detinith thank you. I updated the original post and included the shell script to resume the session from autostart. I was wondering how to support multiple conky's and your idea just seems so elegant and simple  cool

Dis 'n plesier. Detinith is around but too busy to respond lately, I'll pass along the thanks smile Also I've added in the 'killall' functionality but I think the toggle switch is too cumbersome. Better to make each conky group a menu with the items 'add' and 'kill'. See the following.

Sector11 wrote:

Now if that could be activated in the python script for the pipemenu you wouldn't need  separate directories for the conkys or one (or more) conky repeated in various directories to get different layouts with multiple conkys.

The way I'm reading this is you would like to have the pipemenu list all the conkies in a folder, and then be able to choose which ones to start and which ones to kill from the menu being able to accumulate conkies and remove them piecemeal, correct? This is pretty simple with the commands you've given, but I think it would require a reversion back to the original code @kbmonkey posted. I think it might be better to stick with the directory structure we've added to add or remove groups of conkies instead of one at a time.

First we'll import a new library at the top of the code:

import fileinput

Second change the menu generator:

def buildConkyMenuItem(configPath):
    """
    Build an openbox menu item tag from the given config file path.
    Returns str
    """    
    menuFormat = """
    <menu id="conky - %(label)s" label="%(label)s">
        <item label="Add Conky">
            <action name="Execute">
                <command>
                    %(thisexecutable)s 'add' "%(configpath)s"
                </command>
            </action>
        </item>
        <item label="Remove Conky">
            <action name="Execute">
                <command>
                    %(thisexecutable)s 'kill' "%(configpath)s"
                </command>
            </action>
        </item>
    </menu>
    """

Then a few things must be changed in @kbmonkey's main block. Reproduced in whole here because otherwise it would be difficult to locate:

   if len(sys.argv) == 1:
        CONFIGFILES = list(grabConfigFiles(CONFIGSHOME))
        CONFIGDIRS = []
        for file in CONFIGFILES:
            CONFIGDIRS.append(os.path.dirname(file))
        CONFIGDIRS = list(set(CONFIGDIRS))
        CONFIGDIRS.sort()
        print('<openbox_pipe_menu>')
        for configdir in CONFIGDIRS:
            print(buildConkyMenuItem(configdir))
        print("""
        <separator/>
        <item label="Kill All">
            <action name = "Execute">
                <execute>sh -c 'killall conky ;amp;amp echo "" > $HOME/.conky/session.log'</execute>
            </action>
        </item>
        """)
        print('</openbox_pipe_menu>')
    else:
        configFiles = list(grabConfigFiles(sys.argv[2]))

        if str(sys.argv[1]) == "kill":
            for configFile in configFiles:
                ckill="conky -q -c " + configFile
                subprocess.Popen(['pkill', '-xf', ckill ])
                file = open(os.path.join(CONFIGSHOME,'session.log'),"r")
                lines = file.readlines()
                file.close()
                file = open(os.path.join(CONFIGSHOME,'session.log'),"w")
                for line in lines:
                    if line != str(configFile) + "\n":
                        file.write(line)
                file.close()

        if str(sys.argv[1]) == "add":
            file = open(os.path.join(CONFIGSHOME,'session.log'),"a")
            for configFile in configFiles:
                subprocess.Popen(['conky','-q','-c', configFile])
                file.write(configFile + "\n")
            file.close()

Notice the new 'killall command' in the main menu. Though this should probably go on the top - if the list of conky groups gets large this will be hard to find on the bottom.

I've got this working on my setup - the session preservation situation works fine with the added 'file = open(...' and 'file.close()' stuffs.

Give it a shot, let me know what you guys think.

**Sidebar**
Really it's a few keywords to change to make this into a 'tint2' switcher, and a small coding mission to combine a tint2 version with a conky version and make entire "Theme" switchers. Themes of course would have to be mutually exclusive, so no adding, removing. I would love to see this happen. I may be too busy over this weekend to make it happen, but if @kbmonkey wants to crack at it please do. I'll check if @detinith will be free, he's also interested.

**Add to TODO
In addition to the "Killall" item, there should be a "Make New Group" item. Basically it would pop-up a terminal (or some nifty python-tkinter situation if you're feeling frisky) and ask what you want to name the group, it makes a directory in ~/.conky with the name of the group, and then makes symbolic links to all the config files in the 'session.log' file - which is always all the currently opened conkies.
Just thinking out loud smile

Last edited by woodape (2015-03-14 07:52:29)

Offline

#18 2015-03-13 20:57:22

woodape
#! CrunchBanger
From: Cape Town, South Africa
Registered: 2014-03-27
Posts: 113

Re: Conky Switcher (Pipe Menu)

Whoops! That new killall item should be the following:

Edit: have just updated the code in the above...should have done that to begin with 8)

Last edited by woodape (2015-03-13 20:58:56)

Offline

#19 2015-03-13 22:20:49

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky Switcher (Pipe Menu)

woodape wrote:

The way I'm reading this is you would like to have the pipemenu list all the conkies in a folder, and then be able to choose which ones to start and which ones to kill from the menu being able to accumulate conkies and remove them piecemeal, correct? This is pretty simple with the commands you've given, but I think it would require a reversion back to the original code @kbmonkey posted. I think it might be better to stick with the directory structure we've added to add or remove groups of conkies instead of one at a time.

No not what I would like ... I can't code my way out of a wet paper bag. And not trying to step on toes.

All I was suggesting, in very simple terms.

An Example Situation:

In this situation; these exist

  • ~/.conky/top_right.conky

  • ~/.conky/top_line.conky

  • ~/.conky/top_left.conky

  • ~/.conky/bottom_right.conky

  • ~/.conky/bottom_left.conky

The pipemenu shows:
[Top Right]
[Top Line]
[Top Left]
[Bottom Right]
[Bottom Left]
[Killall]

and the bottom_left.conky is running, nothing else.

Clicking on [Top Right] in the pipemenu will start the top_right.conky without killing the bottom_left.conky.  So now you have two conkys running.

Now clicking on the [Bottom Left] entry in the menu shuts that down, because it is running, leaving the top_right.conky running.

The problem I see with the directory structure is the number of times you would need to copy conkys to different directories to get all possible combinations.

  • Directory 1 to 5 just to run those 5 conkys

  • another 4 directories to run each of the four corner conkys with the top_line.conky

    • top_right.conky & top_line.conky

    • top_left.conky & top_line.conky

    • bottom_right.conky & top_line.conky

    • bottom_left.conky & top_line.conky

Right there alone you have:  9 copies of top_line.conky, 6 copies of top_right.conky, 6 copies of top_left.conky, 6 copies of bottom_right.conky, 6 copies of bottom_left.conky.  That's 33 conky files, in 9 directories under ~/.conky, to run one or two of those "IF" the second one is the top_line.conky

Now add directories, with more copies of the files, to run

  • the two top corner conkys

  • the two top left corner conkys

  • the two top corner conkys with the top line conky

  • the two righ... and it goes on ...

With my 'suggestion' if it can work, you only need 5 conky files.

woodape wrote:

being able to accumulate conkies and remove them piecemeal, correct?

Totally lost here, what do you mean by accumulate and remove?

What I am saying is:

[Conky Switcher]»[Top Right] - click on it, one of two things happen:

  1. if top_right.conky is running it is killed without killing any other running conky.

  2. if top_right.conky is not running it is started without killing any other running conky.

Also note I said: 

Sector11 wrote:

Now if that could be activated in the python script for the pipemenu you wouldn't need  separate directories for the conkys or one (or more) conky repeated in various directories to get different layouts with multiple conkys.

kbmonkey's option to try or not.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#20 2015-03-14 03:25:52

smacz
#! Junkie
Registered: 2014-12-09
Posts: 250

Re: Conky Switcher (Pipe Menu)

Great work guys. And awesome concept! It really works with the whole BunsenLabs feel. I'll be putting it through its paces as best as I can ;)

@Sector11, if I understand you correctly then having {load | kill} next to a conky would be helpful to discern what clicking it would do.

For instance, if I pulled up the Conky Switcher in the menu while [Top Left] and [Bottom Right] were running on my desktop after having started them via this same script one at a time, having been able to load one without killing the other (not yet implemented), I might see:

Load [Top Right]
Load [Top Line]
Kill [Top Left]
Kill [Bottom Right]
Load [Bottom Left]
-------------------------
Killall

Where clicking "Kill [Bottom Right]" would kill the process running the bottom right conky thereby removing it from my desktop. Also, clicking "Load [Bottom Left]" would start the bottom left conky without killing the other conkys. Ultimately I would be configuring my desktop piecemeal by cherry-picking which conkys I wanted to have set up at any given time.

And yes, that does assume three changes are made to the program. 1) Launching one conky does not kill the others. 2) Clicking on a conky in the menu can both kill or load it depending on it's current state (see pkill). 3) Adding the annotation to the conky names (but this is more for visual effect than anything else).

Whether or not it is feasible, the concept is understandable. Actually it is exemplified perfectly in the zenity dialog that is up at the github repo under the name blc.

@kbmonkey At this point, the codebase does not appear to differentiate between workspaces. Would then the selcted conky(s) be indiscriminately applied across all workspaces?

Also, I copied the code in the first post after you had updated it 2015-03-13, and selecting a conky other than the one currently displayed kills the first conky and replaces it with the selected one. This appears to be the expected behavior (8th to last line under the "else:" clause..."'killall', 'conky'"). If so, what was meant by "Support for multiple conkys" in the update notes?

Lastly, in regards to the last "TODO", IIRC any coloration of the text/background is handled by the ${theme}/openbox-3/themerc file. In Bunsen2-Dark-Blue, the one thing I could think to take advantage of is the "menu.items.disabled.{text | bg}.color" (of which "bg" isn't even present in what hhh had put out). And I don't know if you want the "disabled" color to be the running conky or the non-running ones. Either way, I am unaware of how to code that into the menu yet. I'll see if I can wrap my head around that one sooner or later.

@woodape I agree with your sidebar. This concept lends itself quite nicely to being reused for a tint2 setup. Once a pipemenu is finalized for conky, I would definitely move towards porting it in order to be able to set up tint2 in a similar manner.

Also (I may edit this if I figure it out) I have been unable to get your most recent suggested changes to work. Let me see if there's some glaring error that I've overlooked. I have replaced the "menuFormat" section buildConkyMenuItem function with your code (leaving the "nameWithoutExt" there) and replaced from "if len(sys.argv) == 1:" down with your second code snippet (leaving the "if not os.path.exists(CONFIGSHOME):" block). By that explanation did I take out enough or too little? I'm getting an "Invalid Output" error from Openbox. EDIT: I did find a space after the '<' tag on line...63(???) right before the "menu id=conky" in "menuFormat" that showed up in my .xsession-errors file as an error.

EDIT: Is this python 2 or python 3 or does it even matter?

Last edited by smacz (2015-03-14 07:11:20)

Offline

#21 2015-03-14 07:06:29

woodape
#! CrunchBanger
From: Cape Town, South Africa
Registered: 2014-03-27
Posts: 113

Re: Conky Switcher (Pipe Menu)

Sector11 wrote:

No not what I would like ... I can't code my way out of a wet paper bag. And not trying to step on toes.

No toes stepped on smile but I think the code I posted actually is doing what you described, other than the single click motion. I've set up my switcher to look like your example without the single click motion.

Sector11 wrote:

The pipemenu shows:
[Top Right]
[Top Line]
[Top Left]
[Bottom Right]
[Bottom Left]
[Killall]

pipemenu

I've moved the killall because I like it better on top wink

Sector11 wrote:

and the bottom_left.conky is running, nothing else.

Clicking on [Top Right] in the pipemenu will start the top_right.conky without killing the bottom_left.conky.  So now you have two conkys running.

Before:
before

Middle:

middle

Sector11 wrote:

Now clicking on the [Bottom Left] entry in the menu shuts that down, because it is running, leaving the top_right.conky running.

After:
after


Sector11 wrote:

The problem I see with the directory structure is the number of times you would need to copy conkys to different directories to get all possible combinations.

  • Directory 1 to 5 just to run those 5 conkys

  • another 4 directories to run each of the four corner conkys with the top_line.conky

    • top_right.conky & top_line.conky

    • top_left.conky & top_line.conky

    • bottom_right.conky & top_line.conky

    • bottom_left.conky & top_line.conky

Right there alone you have:  9 copies of top_line.conky, 6 copies of top_right.conky, 6 copies of top_left.conky, 6 copies of bottom_right.conky, 6 copies of bottom_left.conky.  That's 33 conky files, in 9 directories under ~/.conky, to run one or two of those "IF" the second one is the top_line.conky

Now add directories, with more copies of the files, to run

  • the two top corner conkys

  • the two top left corner conkys

  • the two top corner conkys with the top line conky

  • the two righ... and it goes on ...

Yes absolutely, the way it was before needed a massive amount of directories for simple combinations.
Accomplished with the code I posted:

woodape@treebox:~/.conky$ tree --dirsfirst
.
├── Archive
│   ├── chron.conky
│   └── chronograph-12.lua
├── Bottom Left
│   └── chron.conkyrc
├── Bottom Right
│   └── chron.conkyrc
├── Top Left
│   └── chron.conkyrc
├── Top Line
│   └── chron.conkyrc
├── Top Right
│   └── chron.conkyrc
├── conky_restore
└── session.log

6 directories, 9 files
Sector11 wrote:

With my 'suggestion' if it can work, you only need 5 conky files.

With the code as is you only need 5 conky directories. Also, what if you had a pair of conkies you always launched together? Without the directory structure that means 'right click -> conky switcher -> conky1 -> Add' , then 'right click -> conky switcher -> conky2 -> Add'. With the directory structure, it is just 'right click -> conky switcher -> group1 -> Add'. Granted the single click motion would remove the Add part from both methods.

Sector11 wrote:
woodape wrote:

being able to accumulate conkies and remove them piecemeal, correct?

Totally lost here, what do you mean by accumulate and remove?

I meant accumulate on the desktop and remove from the desktop. Different words for adding and killing conkies individually.

Sector11 wrote:

What I am saying is:

[Conky Switcher]»[Top Right] - click on it, one of two things happen:

  1. if top_right.conky is running it is killed without killing any other running conky.

  2. if top_right.conky is not running it is started without killing any other running conky.

This would involve making the one-click action and would be very simple - but the concept of adding adding/killing individual conkies is already working. I wonder though if the single click action would take away functionally that might be wanted in the future. Right now with each conky group as a menu, further items/menus could be added to each conky group menu later down the line. For instance a menu like "Add to Group" which lists all the available groups and then when one is clicked, symbolic-links to all the conkies in the current group are created in the group selected.

However, if for aesthetic reasons you just want the one click action, it could be done easily, but maybe we should wait until the highlighting thing gets sorted? Or else the highlighing can be forgone in favor of @smacz's suggestion of changing the item names conditional on which ones are running. This could be implemented by some conditional logic based on the session.log file.

smacz wrote:
Load [Top Right]
Load [Top Line]
Kill [Top Left]
Kill [Bottom Right]
Load [Bottom Left]
-------------------------
Killall

Offline

#22 2015-03-14 07:08:57

woodape
#! CrunchBanger
From: Cape Town, South Africa
Registered: 2014-03-27
Posts: 113

Re: Conky Switcher (Pipe Menu)

smacz wrote:

If so, what was meant by "Support for multiple conkys" in the update notes?

The support for multiple conkies means that in the original script, individual conkies are replaced by other individual conkies, and the update from @detinith and I changed this so groups of conkies are replaced by other groups of conkies. The most recent script I've added allows for adding and removing groups of conkies without killing all conkies currently open.

smacz wrote:

I did find a space after the '<' tag on line...63(???) right before the "menu id=conky" in "menuFormat" that showed up in my .xsession-errors file as an error.

I believe that's your problem right there smile I've got no space on the version on my machine, though I see the one in the code I posted, I'll get rid of it now.

smacz wrote:

Is this python 2 or python 3 or does it even matter?

I don't think it matters at this point.

Last edited by woodape (2015-03-14 09:13:10)

Offline

#23 2015-03-14 07:26:51

smacz
#! Junkie
Registered: 2014-12-09
Posts: 250

Re: Conky Switcher (Pipe Menu)

@woodape I only questioned the python 2 vs 3 because I had never seen the "%(variable)s" notation before. That's really handy. I'm still also trying to get the script working despite eliminating the space. I've ran the script from the command line, and I don't visually see anything out of the ordinary in stdout, but obmenu gives me a dialog box saying that there's 'Invalid Output from pipe-menu'. Any idea if I can get a more descriptive error anywhere? ".xsession-errors" is not being helpful anymore.

The output that you posted looks like exactly what was being discussed. I'm excited to get it working!

EDIT: Running it on the command line, I realized that I'm not sure what all the arguments are meant to be. What should the index look like for the `sys.argv` list? As far as I gather it should be:

[bl-conky-switcher-pipemenu.py, {kill | add}, ${conky}]

Because

./bl-conky-switcher-pipemenu.py add /home/smacz42/.conky/bl-right

works for me from the command line. So the script itself is solid. And if I move the .conky/ directory to something else, the warning will pop up for me. I'll keep checking my implementation. I never though copying and pasting was so error-prone!

Last edited by smacz (2015-03-14 07:55:22)

Offline

#24 2015-03-14 07:52:09

woodape
#! CrunchBanger
From: Cape Town, South Africa
Registered: 2014-03-27
Posts: 113

Re: Conky Switcher (Pipe Menu)

@smacz - I found the little error in the code I posted. I must have corrected it on my machine and not in the post. The menu generator is missing an end "</menu>" tag. so it should be:

menuFormat = """
    <menu id="conky - %(label)s" label="%(label)s">
        <item label="Add Conky">
            <action name="Execute">
                <command>
                    %(thisexecutable)s 'add' "%(configpath)s"
                </command>
            </action>
        </item>
        <item label="Remove Conky">
            <action name="Execute">
                <command>
                    %(thisexecutable)s 'kill' "%(configpath)s"
                </command>
            </action>
        </item>
    </menu>
    """

I'll change this is my block now. I don't really know where to get more descriptive errors. Though since this is a *.xml format you could redirect the output to a file and get vim or some other program to do syntax checking for you.

I've also never seen the "%(variable)" notation before, but I'm really not that fluent with python, I rely on stackexchange.com to tell me the little bits I need to know.

Last edited by woodape (2015-03-14 07:56:57)

Offline

Be excellent to each other!

#25 2015-03-14 08:02:05

smacz
#! Junkie
Registered: 2014-12-09
Posts: 250

Re: Conky Switcher (Pipe Menu)

Ninja'd!!! I just found it but you beat me to the punch. Although honestly I should have seen that for myself a long time ago... Thank you.

EDIT: I haven't been able to make anything useable thus far, and I have to go pass out for now, but I was working on something similar before this thread and had stumbled across this function to retrieve information about running processes from the /proc filesystem:

import os
import re

pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]

processes = []

for pid in pids:
  try:
    procs = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
    # "% conky" can be whatever term we need to search for
    if re.search("%s" % conky, procs):
      processes.append(procs)
  except IOError: # proc has already terminated
    continue

Hopefully that can help when it comes to determining how we might go about annotating the conkys that can be loaded versus the ones that can be killed by providing a list of running ones.

Last edited by smacz (2015-03-14 09:32:53)

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo