The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
2

Scratchpad indicator in the status bar?

asked Aug 21 '13

anonymous user

Anonymous

Hi. Is it possible to add an indicator in the status bar that shows up when there is a window in the scratchpad, similar to the workspace indicators? It would sometimes be useful to see whether there still is a window open "in the background" without opening the scratchpad. Thanks!

Comments

Good idea. I would like to see something like that.

cee gravatar imagecee (Aug 21 '13)edit

1 answer

Sort by ยป oldest newest most voted
0

answered Aug 21 '13

bruno.braga gravatar image

A bit dirty solution that works could be a simple script that you append to the i3status output (see man for details):

#!/usr/bin/python

import subprocess
import simplejson

def getNodes(data):
    result = 0
    if data['scratchpad_state'] != 'none': 
        result += 1    
    if (len(data['nodes']) > 0) or (len(data['floating_nodes']) > 0):
        for node in (data['nodes'] + data['floating_nodes']):
            result += getNodes(node)
    return result

r = subprocess.check_output(["i3-msg", "-t", "get_tree"])
j = simplejson.loads(r)
c = getNodes(j)

if c > 0:
    print "S:%d" % c
else:
    print ''

You can save this simple script and call it with i3status, which should give similar result to what you are after.

Comments

If you need to output to i3bar in colors, here is a solution that works nicely: https://gist.github.com/brunobraga/6076658 (see the comments)

bruno.braga gravatar imagebruno.braga (Aug 21 '13)edit

Question Tools

Stats

Asked: Aug 21 '13

Seen: 395 times

Last updated: Aug 21 '13