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

Open in specific window

asked 2013-05-15 14:36:16 +0000

iomartin gravatar image

Hello,

There are some websites that I like to keep running in their own windows (instead of tabs), and dedicate a workspace for them (a music workspace, a webmail workspace, etc.). Therefore, I have created simple shell scripts such as

#!/bin/bash
firefox -new-window www.jazzradio.com/guitarjazz

to launch them and added them to my PATH. On my config file, however, I already have

assign [class="Firefox"] 2. www

which opens generic Firefox on the 2. www workspace. How could I configure i3 to open these specific pages in the right workspaces?

I though about using i3-msg, but I figured that even if I change to the correct workspace, when I launch the script it will recognize it as Firefox window and will apply the assign configured in the config file.

edit retag flag offensive close merge delete

Comments

generally, have you considered spreading your browser windows across your workspaces (like treating any website as an application)? because, first, you want to have a radio web application seperated, next can be anything?

dosimple gravatar imagedosimple ( 2013-05-16 12:36:51 +0000 )edit

I'm not sure I got what you mean. Yes, I want to spread my browser windows across workspaces, one for a radio web application, one for webmail and another for general browsing.

iomartin gravatar imageiomartin ( 2013-05-16 12:47:42 +0000 )edit

sorry for the abiguity, i meant reconsidering the `assign [class="Firefox"] 2. www` line altogether, to be direct.

dosimple gravatar imagedosimple ( 2013-05-16 13:08:21 +0000 )edit

2 answers

Sort by » oldest newest most voted
3

answered 2013-05-15 14:43:21 +0000

badboy_ gravatar image

As specified in command_criteria you can also match on title:

[class="Firefox" title="(?i)jazzradio.com"] 3.jazzradio
edit flag offensive delete link more

Comments

great, thanks! I just had to change the regex a little to match it.

iomartin gravatar imageiomartin ( 2013-05-15 15:33:37 +0000 )edit

Actually, I just realized that this was throwing all my Firefox instances to the jazzradio workspace. I think this is related to the fact that I use Vimperator, as noted in the documentation.

iomartin gravatar imageiomartin ( 2013-05-15 17:27:51 +0000 )edit
1

I removed Vimperator, but that didn't solve it. Assigning based on the title doesn't work, since Firefox always creates the windows as "Mozilla Firefox" and only later changes their name - but by then i3 has already catched the window and placed it in the appropriate (current) window.

iomartin gravatar imageiomartin ( 2013-05-27 13:30:07 +0000 )edit
0

answered 2013-05-27 18:15:41 +0000

iomartin gravatar image

Not exactly pretty, but what I did was to remove the Firefox assignment from the config. Then I modified my shell script to the following

CURRENT_WORKSPACE=$(i3_current_workspace_focused.py)
i3-msg "workspace 10. ♪"
firefox -new-window www.jazzradio.com/guitarjazz
sleep 1
i3-msg "workspace $CURRENT_WORKSPACE"

where i3_current_workspace_focused,py is

#!/usr/bin/python

from commands import getoutput
import json

workspaces = getoutput("i3-msg -t get_workspaces")
workspaces = json.loads(workspaces)

for w in workspaces:
    if w['visible'] == True and w['focused'] == True:
        print w['name']
        break
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-05-15 14:36:16 +0000

Seen: 443 times

Last updated: May 27 '13