#hyprland #kde #cli

app hyprkool

一个帮助您在Hyprland中复现KDE活动和桌面网格布局感觉的工具

2个不稳定版本

0.4.0 2024年4月1日
0.3.0 2024年3月25日

#221 in GUI

MITGPL-3.0-or-later

69KB
1.5K SLoC

Hyprkool

一个有偏见的Hyprland插件,试图复现KDE活动和网格布局。

特性

  • 当光标触碰到屏幕边缘时切换桌面
  • 网格布局
  • 为eww和waybar等工具提供信息命令
  • 可选的守护进程,用于状态化命令

限制

  • Hyprland插件还不能控制动画的方向性

安装

Cargo

cargo install --locked hyprkool

从源安装

git clone https://github.com/thrombe/hyprkool
cd hyprkool
cargo install --path .

Nix

试一试

nix run github:thrombe/hyprkool

否则将以下内容添加到您的nix flake中

{
  inputs = {
    ...

    # define flake input
    hyprkool.url = "github:thrombe/hyprkool";
  };

  ...

    # then add it to your environment packages
    packages = [
      inputs.hyprkool.packages."${system}".default
    ];

  ...
}

示例配置

配置hyprkool

~/.config/hypr/hyprkool.toml

# activity names (first activity is treated as default)
activities = ["my-default-activity", "my-activity"]

# number of workspaces in x and y dimensions
workspaces = [2, 2]

[daemon]
# remember last focused workspace in an activity
remember_activity_focus = true

# execute fallback commands if daemon cannot be reached
fallback_commands = true

[daemon.mouse]
switch_workspace_on_edge = true

# how often to poll for cursor position
polling_rate = 300 # in ms

# number of pixels to consider as edge
edge_width = 0

# number of pixels to push cursor inside when it loops around
edge_margin = 2

Hyprland配置

~/.config/hypr/hyprland.conf

animations {
  ...

  # animations work fine, but afaik there is no way to control
  # which side the workspaces slide from as a hyprland plugin
  # so i recommend either turning off animations for workspaces
  # or using animation styles that do not have directionality. (eg fade)
  animation = workspaces, 0
}

# Switch activity
bind = $mainMod, TAB, exec, hyprkool next-activity -c

# Move active window to a different acitvity
bind = $mainMod CTRL, TAB, exec, hyprkool next-activity -c -w

# Relative workspace jumps
bind = $mainMod, h, exec, hyprkool move-left -c
bind = $mainMod, l, exec, hyprkool move-right -c
bind = $mainMod, j, exec, hyprkool move-down -c
bind = $mainMod, k, exec, hyprkool move-up -c

# Move active window to a workspace
bind = $mainMod CTRL, h, exec, hyprkool move-left -c -w
bind = $mainMod CTRL, l, exec, hyprkool move-right -c -w
bind = $mainMod CTRL, j, exec, hyprkool move-down -c -w
bind = $mainMod CTRL, k, exec, hyprkool move-up -c -w

# toggle special workspace
bind = $mainMod, SPACE, exec, hyprkool toggle-special-workspace -n minimized
# move active window to special workspace without switching to that workspace
bind = $mainMod, s, exec, hyprkool toggle-special-workspace -n minimized -w -s

# switch to named focus
bind = $mainMod, 1, exec, hyprkool switch-named-focus -n 1
bind = $mainMod, 2, exec, hyprkool switch-named-focus -n 2
bind = $mainMod, 3, exec, hyprkool switch-named-focus -n 3
# set / delete named focus
bind = $mainMod SHIFT, 1, exec, hyprkool set-named-focus -n 1
bind = $mainMod SHIFT, 2, exec, hyprkool set-named-focus -n 2
bind = $mainMod SHIFT, 3, exec, hyprkool set-named-focus -n 3

# this is optional, but it can provide features like
# - remembering the last focused workspace in an activity
# - switch workspaces when mouse touches screen edges
# - named focus
exec-once = hyprkool daemon -m

信息命令

Hyprkool支持一些额外的信息命令,可以帮助您使用waybar和eww等应用程序构建小部件。

例如,hyprkool info -m active-window打印活动窗口信息。

注意:--monitor或-m标志会无限循环地打印此信息。但是,由于它是基于事件的而不是基于轮询的,因此效率很高。eww(使用deflisten)和waybar(使用exec)都支持这种高效的更新。

Eww配置

示例eww配置可以在我的dotfiles中找到

Waybar配置

它简单地使用Unicode全方块字符'█'来显示活动。看起来像这样
activity status indicator

~/.config/waybar/config

{
  ...

  "custom/hyprkool-workspaces": {
    "format": "{}",
    "return-type": "json",
    "exec": "hyprkool info -m waybar-activity-status"
  },
  "custom/hyprkool-window": {
    "format": "{}",
    "return-type": "json",
    "exec": "hyprkool info -m waybar-active-window",
  },
}

~/.config/waybar/style.css

#custom-hyprkool-workspaces {
  border: none;
  font-size: 7px;
  color: #ebdbb2;
  background: #7c6f64;
  border-radius: 3px;
  padding: 2px;
  margin: 1px;
}

依赖项

~10–21MB
~284K SLoC