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

TMUX in Scratchpad [SOLVED]

asked 2015-06-08 14:41:11 +0000

Iarumas gravatar image

updated 2015-06-11 06:02:23 +0000

Hi,

I'm new to using scratchpad and maybe one of you can help. I want to have a TMUX session in my Scratchpad, automatically executed on startup.

So far, I' using a setup without TMUX like this:

exec --no-startup-id urxvt -name Scratch -e ranger
for_window[class="URxvt" instance="Scratch"] move window to scratchpad, border 1pixel

This is working just fine. What I want to have is something like that:

exec 'urxvt -name Scratch -e tmux new-session -s Scratch -n FM ranger'
exec --no-startup-id 'tmux new-window -n Cal wyrd'
exec --no-startup-id 'tmux new-window -n Music ncmpcpp'

This, however doesn't work. Either a scratchpad is initiated nor a TMUX session.

If I am sending the above commands via 'i3-msg', it does work, which I find rather disturbing.

Any ideas anyone?

Meanwhile I can start up a tmux session using this function in my config.fish:

function scratch
tmux attach -t Scratch 
or begin
   tmux new-session -s Scratch -d -n Music ncmpcpp
   and tmux new-window -n Files ranger
   and tmux new-window -n Cal wyrd
   and tmux new-window -n Todo vit
   and tmux selectw -t 1
   and tmux attach-session -d
end

end

which is invoked by my i3.conf via

exec --no-startup-id urxvt -name Scratch -e fish -c scratch

But it is not handled by the hook

for_window[class="URxvt" instance="^Scratch"] move window to scratchpad, border 1pixel
edit retag flag offensive close merge delete

Comments

Can you confirm that class and instance are set correctly on the urxvt window in your workaround?

Adaephon gravatar imageAdaephon ( 2015-06-09 05:53:28 +0000 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2015-06-09 10:27:33 +0000

Iarumas gravatar image

Hi, thank you for your replies.

The output of xprop for my scratchpad is:

WM_CLASS(String) = "urxvt", "URxvt"
WM_NAME(STRING) = "Scratch:1:Files - <hostname>"

The compound WMName was the reason why I used "^Scratch" in the forwindow class.

edit flag offensive delete link more

Comments

Hi, please use the comment function to reply to answers and other comments. Answers should always answer the original question. That said, it seems that the instance is 'urxvt' instead of 'Scratch'. If you want to match the title, you need `[title="...."]`.

Adaephon gravatar imageAdaephon ( 2015-06-10 08:11:48 +0000 )edit

That's it!! Thank you, now another part of my wm is perfect! And sorry for the wrong posting.

Iarumas gravatar imageIarumas ( 2015-06-11 06:01:45 +0000 )edit
0

answered 2015-06-09 07:28:14 +0000

Adaephon gravatar image

The reason your first extended setup for tmux does not work is twofold:

  1. i3 uses only double quotes for quoting. That means any single quotes are not interpreted by i3 (config or i3-msg) in any way. So if you write

    exec 'urxvt -name Scratch -e tmux new-session -s Scratch -n FM ranger'
    

    in your configuration, i3 will not remove the single quotes and tries to run the command with the name'urxvt -name Scratch -e tmux new-session -s Scratch -n FM ranger' instead of urxvt with the rest as arguments.

    Either do not quote (as in your first example) or use double quotes.

  2. Even with correct quoting it is not guaranteed that the URxvt window and the contained tmux instance are up and running when the tmux new-window commands are run as i3 just executes the commands as soon as it encounters them in the configuration without waiting in between.


Your current solution with offloading all tmux related stuff into a script or function and then only running URxvt (with the script or function as argument) directly from the i3 configuration is exactly how I would solve this issue. And from what you posted there should be no reason why it should not work with the for_window configuration.

Here are a few things you can try to debug this:

  • use "Scratch" instead of "^Scratch" as it seemed to work in your initial example, although both should be fine.
  • check the class and instance of the URxvt window with xprop (or similar), if they indeed match "URxvt" and "Scratch".
  • try if the hook works if you replace fish -c scratch with another command, for example sh or ranger as before.
  • maybe try to replace the fish function with a simple sh script.
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-06-08 14:41:11 +0000

Seen: 303 times

Last updated: Jun 11