You are not logged in.

#976 2013-09-16 16:43:32

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: The i3 thread

Hey guys, is there a way to make an application pop up on a click event?

I want a calendar (gsimplecal) to pop-up when I click the clock.

I saw this patch -> http://infra.in.zekjur.net/pipermail/i3 … 01116.html

but, I don't think this is in the codebase.

Alternatively, can this be achieved using conky (running with i3bar)?

Offline

#977 2013-09-16 17:31:09

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: The i3 thread

x33a wrote:

Hey guys, is there a way to make an application pop up on a click event?

I want a calendar (gsimplecal) to pop-up when I click the clock.

I saw this patch -> http://infra.in.zekjur.net/pipermail/i3 … 01116.html

but, I don't think this is in the codebase.

Alternatively, can this be achieved using conky (running with i3bar)?

Click events are a part of i3 already, http://i3wm.org/docs/i3bar-protocol.html section 2.3. It's not explained clearly, but basically it writes json entries to stdin of your status process, and leaves everything else to it. I'm not familiar with conky, but it should have some gizmo to read stdin. Writing some logic to parse clickevent and execute an arbitrary command shouldn't be too difficult.


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#978 2013-09-16 17:37:22

progandy
Member
Registered: 2012-05-17
Posts: 5,262

Re: The i3 thread

If you have a normal i3status running, you could try to wrap it in some script that delegates stdout to i3status and interprets the stdin, e.g. with a read loop ad jshon. Launch programs with "i3-msg exec ... "

Last edited by progandy (2013-09-16 17:38:53)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#979 2013-09-17 00:27:47

ajbibb
Member
Registered: 2012-02-12
Posts: 142

Re: The i3 thread

This post is for anyone interested in adding custom fields into the i3status output stream for display in the i3bar.  I've put together a small BASH script to be called by your i3bar that uses the jshon package from [community] to format the custom text fields.  The script should be easily adaptable for any text you want to display.  All of the i3bar field attributes can be easily defined using jshon and this script, and you may insert your custom field into any position in the bar.     

The script contains functions to create three text fields.  Two of them are are particular to my setup, but I think they are useful to show how to create a JSON object and insert it.  The third is a caps/num lock indicator that should work on any system.
 
Script can be found at this link:
https://www.dropbox.com/s/mx5iiraj9oxax60/i3_bar_1.sh

Offline

#980 2013-09-17 13:31:42

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: The i3 thread

@ kaszak696 and progandy

thanks for the hints, I'll experiment around.

Offline

#981 2013-09-18 08:42:41

okraits
Member
From: Germany
Registered: 2006-03-02
Posts: 142
Website

Re: The i3 thread

This is a crosspost from the i3 screenshot/config thread.

I have developed a script named i3-theme. Its purpose is
to easily set and switch between several sets of
configuration options ("themes") for the i3 window
manager. These sets of configuration options are supposed
to contain options regarding the looks of the window
manager, that is window colors, borderstyle, i3bar colors,
fonts, etc.
There's a bunch of theme files which are distributed
together with the i3-theme script to give the user a
variety of configurations to choose from.

The tarball containing the script, the themes and a README
can be found at:

http://www.okraits.de/upload/i3-theme-0.4.tar.gz

Please feel free to send me feedback and contributions
regarding bugreports, feature requests, improvements,
themes, etc. via mail at okraits at arcor.de. You can also
contact me on irc.twice-irc.de in #i3.

I'm looking forward to your feedback.

Greetings,

Oliver

Edit: Uploaded v0.4 - improved script and added themes - check the README.

Last edited by okraits (2013-09-18 20:53:20)

Offline

#982 2013-09-20 10:30:20

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: The i3 thread

I played around a bit with getting gsimplecal to popup, it's not as obnoxious as i thought it would. Here's how i did it:

I added these lines to i3 config to make gsimplecal window to have floating by default and always appear in the same spot:

for_window [class="Gsimplecal"] floating enable
for_window [class="Gsimplecal"] move absolute position 1189px 605px

Then i wrote this class for my python statusbar app to run in a separate thread and open\close the calendar on click:

import json
import sys
from subprocess import Popen, DEVNULL

class ClickEventHandler(Thread):
    '''
    Handle Click events.
    '''
    def __init__(self, **kwargs):
        Thread.__init__(self, **kwargs)
        self.daemon = True
        self.calendar_name = 'gsimplecal'
        self.event_name = 'Date'
        self.calendar = None
        
    def run(self):
        for event in sys.stdin:
            if event.startswith('['):
                continue
            elif event.startswith(','):
                event = event.lstrip(',')
            
            name = json.loads(event)['name']
            
            if name == self.event_name:
                if self.calendar == None:
                    self.calendar = Popen(self.calendar_name, stdout=DEVNULL)
                else:
                    self.calendar.terminate()
                    self.calendar = None
            else:
                pass

It's crude, but gets the job done.


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#983 2013-09-20 16:07:16

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: The i3 thread

@ kaszak696

cool smile

Also, I didn't know that i3 could move windows to a particular position!

As for getting gsimplecal + click events to work, I gave up. I can't find a way to do so with conky + i3bar. And I am not willing to let go of conky. I did request the maintainer of gsimplecal to add tray support, but I doubt he'll agree tongue

Edit: clarified the software I am talking about.

Last edited by x33a (2013-09-20 17:06:48)

Offline

#984 2013-09-20 16:55:39

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,912
Website

Re: The i3 thread

i3bar does have tray support


Mr Green

Offline

#985 2013-09-20 17:05:41

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: The i3 thread

Mr Green, I meant the gsimplecal maintainer.

Of course I know i3 has tray support, it was one of the reasons I gave up dwm tongue

Offline

#986 2013-09-20 17:09:30

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,912
Website

Re: The i3 thread

My bad smile .....


Mr Green

Offline

#987 2013-09-20 17:32:55

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: The i3 thread

x33a wrote:

As for getting gsimplecal + click events to work, I gave up. I can't find a way to do so with conky + i3bar.
Edit: clarified the software I am talking about.

The solution is rather simple, really. All you need is a 'middle man' between conky and i3bar. Here it shows that you need to use a wrapper script anyway, so is should be possible to hack click events into it. I can try to make it work, but i'm shit with bash tongue


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#988 2013-09-20 17:40:26

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,912
Website

Re: The i3 thread

I am sitting here thinking what is the advantage over using a click event to a keyboard shortcut?


Mr Green

Offline

#989 2013-09-20 18:34:23

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: The i3 thread

Mr Green wrote:

I am sitting here thinking what is the advantage over using a click event to a keyboard shortcut?

For giggles, i guess wink It's kinda cool, and saves a keybind that could be used for something more useful. Anyway, i think this will work, although no one should trust my mad bash skillz:

#!/bin/sh

echo '{"version":1, "click_events": true }'
echo '['
echo '[],'

exec conky -c $HOME/conkyrc &

CAL_PID=0
NAME="Date"

while read -r line
do
    if [ "$line" = "[" ]
    then
        continue
    fi
    line=`echo $line | sed "s/^,//"`
    getname=`echo $line | jshon -e name -u`
    if [ "$getname" = "$NAME" ] 
    then
        if [[ $CAL_PID -eq 0 ]] 
        then
            gsimplecal &
            CAL_PID=$!
        else
            kill $CAL_PID
            CAL_PID=0
        fi
    fi
done

Depends on jshon.


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#990 2013-09-20 18:59:50

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,912
Website

Re: The i3 thread

Not working for me yet, do you have the conkyrc that works with this? Am assuming its looking for the word 'Date'


Mr Green

Offline

#991 2013-09-20 19:09:42

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: The i3 thread

Mr Green wrote:

Not working for me yet, do you have the conkyrc that works with this? Am assuming its looking for the word 'Date'

I used my own python script to test it, not conky, but the protocol is the same, so it should work either way. Conky should output date string like this:

{"name": "Date", "full_text": "20-09-2013 21:02"}

, so i3bar knows the name field. During click event, it'll write something like this to it's standard input:

{"name":"Date","button":1,"x":1288,"y":767}

Notice that the name field allows proper identification. Script i wrote checks whether click event's name field is 'Date' and if it is, does the calendar magic.


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#992 2013-09-20 19:14:48

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,912
Website

Re: The i3 thread

I get this from my conkyrc as output

{ "full_text" : "Fri 20th Sep 20:10 " , "color" : "#D3D3D3"} ],

Mr Green

Offline

#993 2013-09-20 19:21:46

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: The i3 thread

It's not rocket science, let's say you have this line in your conkyrc:

{ "full_text" : "${time}" , "color" : "#D3D3D3"} ],

change it to:

{ "name" : "Date" , "full_text" : "${time}" , "color" : "#D3D3D3"} ],

Last edited by kaszak696 (2013-09-20 19:22:17)


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#994 2013-09-20 19:23:03

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,912
Website

Re: The i3 thread

No that is brain surgery lol... I can see it now.... yay it works now just got to tweak window

Last edited by Mr Green (2013-09-20 19:24:22)


Mr Green

Offline

#995 2013-09-21 05:53:06

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: The i3 thread

kaszak696 wrote:

The solution is rather simple, really. All you need is a 'middle man' between conky and i3bar. Here it shows that you need to use a wrapper script anyway, so is should be possible to hack click events into it.

I was using plain old text output with no json and hence no colours or fancy stuff. Now, thanks to your nudging, I decided to use the json stuff with my conky.

kaszak696 wrote:
Mr Green wrote:

I am sitting here thinking what is the advantage over using a click event to a keyboard shortcut?

For giggles, i guess wink It's kinda cool, and saves a keybind that could be used for something more useful.

I am trying to save space on my i3bar (15" monitor). So I decided that I'll only show the time, while the date will be taken care by a calendar. While I am a keyboard person mostly, I felt that a mouse click over the clock will be more appropriate in this case.

Anyway, i think this will work, although no one should trust my mad bash skillz.

Your script works perfectly, thanks.

Offline

#996 2013-09-21 07:18:58

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,912
Website

Re: The i3 thread

Think adding a case statement would increase number of clickable objects, do like the idea of a floating terminal displaying htop.....or clicking volume for alsamixer.....

@x33a do not take my comments to heart was just thinking out loud (this is pretty cool).

Last edited by Mr Green (2013-09-21 09:43:09)


Mr Green

Offline

#997 2013-09-21 09:32:40

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: The i3 thread

@ Mr Green, no problem. You had a genuine question, especially in a tiling wm thread tongue

Offline

#998 2013-09-25 06:41:37

okraits
Member
From: Germany
Registered: 2006-03-02
Posts: 142
Website

Offline

#999 2013-09-25 11:02:05

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,912
Website

Re: The i3 thread

You thought about setting up a git page others might want to help out?


Mr Green

Offline

#1000 2013-09-25 13:09:22

okraits
Member
From: Germany
Registered: 2006-03-02
Posts: 142
Website

Re: The i3 thread

i3-theme has been renamed to j4-make-config because it might be included in http://www.j4tools.org/ and it will provide more general configuration generation functionality soon:

http://www.okraits.de/index.php?section … ake-config

Other changes:

- added dwm theme
- move current solarized theme to solarized_mod theme
- added new exact solarized theme

Last edited by okraits (2013-10-05 22:51:32)

Offline

Board footer

Powered by FluxBB