#ipc #sway #swaywm #async #swayipc

app persway

Sway IPC守护进程

9个版本

0.6.2 2023年3月8日
0.6.1 2023年3月8日
0.6.0 2023年2月23日
0.4.1 2021年2月17日
0.3.5 2020年2月27日

265异步 中排名

每月 21 次下载

MIT 许可证

62KB
1.5K SLoC

https://user-images.githubusercontent.com/28332/223278211-ba3943ee-becc-45e5-ae0e-4f1a121a6f17.mp4

Persway - 计划、邪恶的Sway ipc守护进程

Persway与Sway Compositor一起工作,说服它做一些小坏事。它具有窗口焦点处理器,可以用来调整焦点和非焦点窗口的透明度等许多其他事情。Persway目前支持两种布局:spiralstack_main。前者根据窗口几何形状在水平和垂直分割之间交替 - 这通常会产生类似螺旋的东西,这种布局与persway之前所称呼的 autolayout 相同。后者,即 stack_main,在较大主区域的侧面保持窗口堆栈(这种布局有时被称为master stack)。Persway附带了一些命令来控制在其内部移动时的 stack_main 布局。Persway通过套接字与自身通信,并通过Sway套接字监听Sway事件,使其成为操作 Sway Compositor 的灵活工具。

Persway版本0.6.0中对CLI界面进行了向后不兼容的更改。然而,更改很小,之前版本的所有选项和参数现在都可在 daemon 子命令下找到。因此,迁移路径很简单

如果您的先前预0.6.0设置如下

persway -w -e '[tiling] opacity 1' -f '[tiling] opacity 0.95; opacity 1' -l 'mark --add _prev' --autolayout 

在0.6.0及更高版本上的相同设置应如下所示

persway daemon -w -e '[tiling] opacity 1' -f '[tiling] opacity 0.95; opacity 1' -l 'mark --add _prev' --default-layout spiral

进行此更改是因为,如上所述,Persway获得了与自身通信的能力。也就是说,在版本0.6.0中,Persway可以通过套接字与自身通信以执行各种操作。

这是主要的CLI界面

I am Persway. An evil, scheming, friendly daemon.

I talk to the Sway Compositor and persuade it to do little evil things. Give me an option and see what it brings. I also talk to myself.

Usage: persway [OPTIONS] <COMMAND>

Commands:
  daemon
          Starts the persway daemon
  stack-focus-next
          Applies to stack main layout - focuses the next stacked window
  stack-focus-prev
          Applies to stack main layout - focuses the previous stacked window
  stack-swap-main
          Applies to stack main layout - swaps the current stacked window with the main window
  stack-main-rotate-next
          Applies to stack main layout - pops the top of the stack into main while pushing the old main window to the bottom of the stack
  change-layout
          Changes the layout of the focused workspace
  help
          Print this message or the help of the given subcommand(s)

Options:
  -s, --socket-path <SOCKET_PATH>
          Path to control socket. This option applies both to daemon and client. Defaults to <XDG_RUNTIME_DIR>/persway-<WAYLAND_DISPLAY>.sock

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

守护进程CLI界面

Starts the persway daemon

Usage: persway daemon [OPTIONS]

Options:
  -d, --default-layout <DEFAULT_LAYOUT>
          Which layout should be the default when no other layout has been specified for a workspace. Options are: manual, spiral and stack_main
          
          [default: manual]

  -w, --workspace-renaming
          Enable automatic workspace renaming based on what is running in the workspace (eg. application name)

  -f, --on-window-focus <ON_WINDOW_FOCUS>
          Called when window comes into focus. To automatically set the opacity of all other windows to 0.8 for example, you would set this to:
          
          [tiling] opacity 0.8; opacity 1
          
          Eg. set all tiling windows to opacity 0.8 but set the currently focused window to opacity 1. Or if you want to skip some applications - in this case firefox - you would do something like:
          
          [tiling] opacity 0.8; [app_id="firefox"] opacity 1; opacity 1

  -l, --on-window-focus-leave <ON_WINDOW_FOCUS_LEAVE>
          Called when window leaves focus. To automatically mark these for example, you would set this to:
          
          mark --add _prev
          
          and then in your sway config:
          
          bindsym Mod1+tab [con_mark=_prev] focus

  -e, --on-exit <ON_EXIT>
          Called when persway exits. This can be used to reset any opacity changes or other settings when persway exits. For example, if changing the opacity on window focus, you would probably want to reset that on exit like this:
          
          [tiling] opacity 1
          
          Eg. set all tiling windows to opacity 1

  -h, --help
          Print help (see a summary with '-h')

change-layout 子命令接受布局子命令

Changes the layout of the focused workspace

Usage: persway change-layout <COMMAND>

Commands:
  spiral      The spiral autotiling layout tiles windows in a spiral formation, similar to AwesomeWM
  stack-main  The stack_main autotiling layout keeps a stack of windows on the side of a larger main area, this layout comes with a few commands to control it as well
  manual      The normal sway manual tiling
  help        Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

change-layout stack-main 子命令接受一些选项

The stack_main autotiling layout keeps a stack of windows on the side of a larger main area, this layout comes with a few commands to control it as well

Usage: persway change-layout stack-main [OPTIONS]

Options:
  -s, --size <SIZE>                  Size of the main area in percent [default: 70]
  -l, --stack-layout <STACK_LAYOUT>  The sway layout of the stack: tabbed, tiled or stacked [default: stacked]
  -h, --help                         Print help

还有其他子命令。去探索吧。

如果您在命名/编号工作空间以及切换工作空间时遇到问题,请参阅此问题评论:https://github.com/johnae/persway/issues/2#issuecomment-644343784 - 它的核心是可能是 sway 配置问题。

Nix flake

如果您正在使用 NixOS 或者您正在使用 Nix 软件包管理器,您可以轻松地使用此存储库中的 flake 和 overlay(当然,如果您使用的是 Nix flake)。

Persway 是在 MIT 许可下发布的。

依赖关系

~11–25MB
~330K SLoC