Sway: Verify sway commands match i3 commands

Created on 23 Jul 2018  路  30Comments  路  Source: swaywm/sway

Find a list of i3 commands and make sure we have all of them in sway (at least all the ones we want to have). Double check that each sway implementation supports the same arguments as the i3 equivalents.

Criteria:

  • [x] class

    • [x] __focused__

  • [x] instance

    • [x] __focused__

  • [x] window_role

    • [x] __focused__

  • [x] window_type

    • [x] normal, dialog, utility, toolbar, splash, menu, dropdown_menu, popup_menu, tooltip, notification

  • [x] id
  • [x] title

    • [x] __focused__

  • [x] urgent

    • [x] latest/newest/last/recent (sway: only latest)

    • [x] oldest/first (sway: only oldest)

  • [x] workspace

    • [x] __focused__

  • [x] con_mark
  • [x] con_id

    • [x] __focused__

  • [x] floating
  • [x] tiling

Commands:

  • [x] exec [--no-startup-id]

    • [x] command chaining

    • [x] exec quoting

  • [x] split

    • [x] split vertical|horizontal|toggle

    • [x] splith

    • [x] splitv

    • [x] splitt

  • [x] layout

    • [x] layout default|tabbed|stacking|splitv|splith (sway: default possible but not documented)

    • [x] layout toggle [split|all] (sway: all is ignored)

    • [x] layout toggle [split|tabbed|stacking|splitv|splith] [split|tabbed|stacking|splitv|splith] (sway: anything except split is ignored)

  • [x] focus

    • [x] \ focus (undocumented)

    • [x] focus left|right|down|up

    • [x] focus parent|child|floating|tiling|mode_toggle

    • [x] focus output left|right|up|down|primary|\ (sway: no primary)

    • [x] focus mode_toggle

  • [x] move

    • [x] move [\ px] (sway: documentation does not specify px can be included)

    • [x] move [absolute] position [px] [px] (sway: absolute ignored)

    • [x] move [absolute] position center (sway: absolute ignored)

    • [x] move position mouse (sway: allows "absolute")

    • [x] move window|container to mark \

    • [x] move container|workspace to output left|right|down|up|current|primary|\ (sway: no primary; allows "window")

  • [x] swap container with id|con_id|mark \
  • [x] sticky enable|disable|toggle
  • [x] workspace

    • [x] workspace next|prev|next_on_output|prev_on_output

    • [x] workspace back_and_forth

    • [x] workspace [--no-auto-back-and-forth] \ (sway: no --no-auto-back-and-forth)

    • [x] workspace [--no-auto-back-and-forth] number \ (sway: no --no-auto-back-and-forth)

    • [x] move [--no-auto-back-and-forth] [window|container] [to] workspace \ (sway: no --no-auto-back-and-forth; "to" has to be included)

    • [x] move [--no-auto-back-and-forth] [window|container] [to] workspace number \ (sway: no --no-auto-back-and-forth; "to" has to be included; undocumented)

    • [x] move [window|container] [to] workspace prev|next|current (sway: current undocumented)



      • [x] move container to workspace back_and_forth



    • [x] Also can be identified with both: "number \: \"

    • [x] rename workspace [\] to

  • [x] resize

    • [x] resize grow|shrink [\ px [or \ ppt]]

    • [x] resize set \ [px|ppt] \ [px|ppt] (sway: no ppt) (#1737)

  • [x] mark

    • [x] mark [--add|--replace] [--toggle] \

    • [x] unmark \

  • [x] title_format \

    • [x] Pango placeholders: %title, %class, %instance

  • [x] border

    • [x] border normal|pixel [\]

    • [x] border none|toggle

  • [x] shmlog

    • [x] shmlog

    • [x] shmlog on|off|toggle

  • [x] debuglog on|off|toggle
  • [x] restart
  • [x] reload
  • [x] exit
  • [x] scratchpad

    • [x] move scratchpad (sway: also allows "to")

    • [x] scratchpad show

  • [x] nop [\]
  • [x] bar

    • [x] bar hidden_state hide|show|toggle [\]

    • [x] bar mode dock|hide|invisible|toggle [\]

  • [x] mode
  • [x] floating enable|disable|toggle
  • [x] fullscreen
  • [x] kill

Configuration:

  • [x] comments
  • [x] font (sway: can be command)
  • [x] Bindings

    • [x] Keyboard: bindsym|bindcode [--release] [\+][\+] command

    • [x] Mouse: bindsym [--release] [--border] [--whole-window] [--exclude-titlebar] [\+]button\ command

  • [x] mode [--pango_markup] \
  • [x] floating_modifier \ (sway: also includes normal|inverse)
  • [x] floating_mimum_size \ x \
  • [x] default_orientation horizontal|vertical|auto (default follows on monitor size)
  • [x] workspace_layout default|stacking|tabbed (sway: can be command; allows auto)
  • [x] Default border (default: normal)

    • [x] default_[floating_]border normal|none|pixel

    • [x] default_[floating_]border normal|pixel \

  • [x] hide_edge_borders none|vertical|horizontal|both|smart (default: none)
  • [x] for_window \ \
  • [x] no_focus \
  • [x] set $\ \ (sway: can be command, despite documentation; if \ is given without $, the $ is silently added instead of error)
  • [x] set_from_resource $\ \
  • [x] Assign (sway: can be command)

    • [x] assign \ [鈫抅 [workspace] [number] \ (sway: no number)

    • [x] assign \ [鈫抅 output left|right|up|down|primary|\ (sway: undocumented)

  • [x] exec[_always] [--no-startup-id] \
  • [x] workspace \ output \ (sway: can be command)
  • [x] Colors:

    • [x] \ \ \ \ \

    • [x] colorclass: client.focused client.focused_inactive client.unfocused client.urgent client.placeholder client.background

  • [x] ipc-socket \ (default: /tmp/i3-%u.XXXXXX/ipc-socket.%p)
  • [x] focus_follows_mouse yes|no (default: yes) (sway: does not document that the default is yes)
  • [x] mouse_warping output|none (default: output)
  • [x] popup_during_fullscreen smart|ignore|leave_fullscreen (default: smart)
  • [x] focus_wrapping yes|no|force (default: yes)
  • [x] force_focus_wrapping yes|no (deprecated)
  • [x] force_xinerama yes|no (default: no)
  • [x] workspace_auto_back_and_forth yes|no (default: no) (sway: can be command)
  • [x] force_display_urgency_hint \ ms (default: 500)
  • [x] focus_on_window_activation smart|urgent|focus|none (default: smart)
  • [x] show_marks yes|no (default: yes) (marks starting with _ will never be drawn) (sway: can be command)
  • [x] line continuation \
  • [x] bar

    • [x] i3bar_command \ (passed to "sh -c") (default: i3bar) (sway: uses swaybar instead of i3bar)

    • [x] status_command \ (passed to "sh -c")

    • [x] mode dock|hide|invisibile (default: dock)

    • [x] hidden_state hide|show (default: hide)

    • [x] modifier \|none (default: Mod4)

    • [x] bindsym [--release] button\ \

    • [x] id (default: bar-x) (sway: default is not documented)

    • [x] position top|bottom

    • [x] output primary|\

    • [x] tray_output none|primary|\

    • [x] tray_padding \ [px] (default: 2)

    • [x] font \

    • [x] separator_symbol \ (default: vertical)

    • [x] workspace_buttons yes|no (default: yes)

    • [x] strip_workspace_buttons yes|no (default: no)

    • [x] binding_mode_indicator yes|no (default: yes)

    • [x] Colors:



      • [x] background, statusline, separator, focused_background (fallback: background), focused_statusline (fallback: statusline), focused_separator (fallback: separator), focused_workspace, active_workspace, inactive_workspace, urgent_workspace, binding_mode (fallback: urgent_workspace)



Sway-exclusive:

  • clipboard \
  • layout auto
  • layout auto [master|ncol] [inc|set] \
  • move
  • floating_scroll
  • gaps (TODO: check against i3-gaps)
  • output
  • seamless_mouse
  • include
  • swaybg_command
  • swaybar_command
  • input
  • seat
  • opacity
  • urgent enable|disable|allow|deny

Most helpful comment

Hooray! Thank you so much @SirCmpwn and all contributors for making this happen. This project is so exciting, as is wl-roots. Huge shoutout to everyone volunteering hours of their lives to make this work, and many thanks!

All 30 comments

There are at least some commands that don't support the same boolean representations, for example focus_wrapping. sway only allows yes, no and force. i3 allows anything.
force is matched the same,
yes can be anything that eval_boolstr recognizes (1, yes, on, true, enable, active)
no is everything else

We should probably use something similar to eval_boolstr ourselves.

Made a start. Most seems to be there, mainly issues of documentation.

@SirCmpwn moved this list into the top-level description so that GitHub can track the progress of this issue

Thanks for putting that list together, much appreciated! I went through and crossed out some things that don't make sense for sway to implement.

  • [ ] font (sway: can be command)
  • [ ] workspace_layout default|stacking|tabbed (sway: can be command; allows auto)
  • [ ] set $ (sway: can be command, despite documentation; if is given without $, the $ is silently added instead of error)
  • [ ] workspace output (sway: can be command)
  • [ ] workspace_auto_back_and_forth yes|no (default: no) (sway: can be command)
  • [ ] show_marks yes|no (default: yes) (marks starting with _ will never be drawn) (sway: can be command)

Can you elaborate on these? Are these just differences with i3 rather than things sway is missing (save for better set docs)?

  • clipboard
  • seamless_mouse

These aren't present on master, was this list prepared against 0.15?

was this list prepared against 0.15?

I accidentally started on the 0.15 docs and when I switched to the 1.0 docs I forgot to check ones that were removed.

The ones that I put "can be command" means that in i3, they're only supposed to be used in the config file but in sway they can also be executed at runtime. I don't know if you want to change it. Otherwise, it works as well as in i3.
(I was going to put a note about that in the original comment but forgot)

I also noticed a few markdown escapes I missed, I'll fix that.

Gotcha, thanks

Actually, if primary outputs aren't being supported you can mark them off.

Good call, updated.

i3-gaps:

  • [x] gaps (though setting for workspace syntax is slightly different)
  • [x] smart_gaps on|off
  • [x] smart_borders on|no_gaps|off
  • [x] hide_edge_borders smart_no_gaps

I noticed that "tiling" and "floating" criteria do not work.
Ex. for_window [tiling] border none yields error that Token 'tiling' is not recognized. The same happens if using floating criterion.
EDIT: forgot to mention, using version 1.0 alpha 6.

Thanks @martinsb, @RyanDwyer fixed that in #2755.

All done! Special thanks to @ianyfan for their hard work on shoring this up.

Hooray! Thank you so much @SirCmpwn and all contributors for making this happen. This project is so exciting, as is wl-roots. Huge shoutout to everyone volunteering hours of their lives to make this work, and many thanks!

New stuff in i3 4.16:

Can you open a new ticket for those things?

A new ticket for each or a single for all?

Up to you.

disclaimer: never used i3 and really new to this all.
And I know this is hackish/defeating.
But those lines in config should work isn't it?
for_window [class="[.]*"] floating enable, focus;
I also tried this one:
for_window [id="[.]*"] floating enable, focus;
yet I get Token 'class' is not recognized
respectively Token 'id' is not recognized

Should I open a new bug?

Yes. And send a patch

3653

@ddevault: I would take years to send a patch there really sorry, just hope this gets tackled before.

That's total horseshit.

What about set_from_resource? It's strikethrough'd in the issue, but not sure if it's implemented, this breaks compatibility with i3 configs

What about set_from_resource?

set_from_resource loads a value from the X resource database. Sway does not use the X resource database and there is not a Wayland equivalent.

set_from_resource loads a value from the X resource database. Sway does not use the X resource database and there is not a Wayland equivalent.

You're right, appearently this is what the i3 guide says.
I was using set_from_resource $user echo "$USER" which actually work for getting your username into i3 config to write multi-user configs. It also works for reading any other env variable.
Is there another way to read env variables in sway config?

I was using set_from_resource $user echo "$USER" which actually work for getting your username into i3 config to write multi-user configs. It also works for reading any other env variable.

You can just replace it with set $user $USER (or better yet, just replace all instances of $user with $USER). See https://www.reddit.com/r/i3wm/comments/4zq30r/is_there_a_way_to_use_bash_environmental/d6y50tt/

Is there another way to read env variables in sway config?

No, there is no way to read an environment variable's value into a sway variable

You can use command substitution in include directives, e.g. include `hostname`.conf.

Couldn't find a more relevant issue for this:

set $<name> <value> doesn't work inside mode <name> {} blocks, which doesn't match i3's behavior.

Is that a bug, an intentional divergence, or an oversight?

Also, @RedSoxFan, i3's set_from_resource $<name> <resource_name> <fallback> does allow for the inclusion of a fallback. If drop-in compatibility with i3 configurations is desired, sway could just interpret set_from_resource commands including <fallback> args as set $<name> <value (fallback)>.

In interpreting my 450 line i3 config file, those are the only two stumbles sway had.

set $<name> <value> doesn't work inside mode <name> {} blocks, which doesn't match i3's behavior.
Is that a bug, an intentional divergence, or an oversight?

I think this is an oversight since they don't really have any relation to modes since they are not scoped. I'll submit a PR to allow it -- Submitted as #3940

sway could just interpret set_from_resource commands including <fallback> args as set $<name> <value (fallback)>

I have no problem submitting a PR to add this for i3 compatibility and just documenting that the fallback is always used and the command only exists for compatibility with i3 configs. @ddevault @emersion any objections?

I'd rather not implement set_from_resource, no.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Olie440 picture Olie440  路  4Comments

mcmfb picture mcmfb  路  3Comments

emersion picture emersion  路  4Comments

RyanDwyer picture RyanDwyer  路  3Comments

ddevault picture ddevault  路  4Comments