Skip to content

Commit

Permalink
Change default keybinds
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottatop committed Aug 7, 2024
1 parent f5aabd5 commit 503cc06
Show file tree
Hide file tree
Showing 13 changed files with 238 additions and 499 deletions.
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,9 @@ just install run -- -c ./api/lua/examples/default
cargo run -- -c ./api/rust/examples/default_config
```
When running without compiled Snowcap integration,
use the following directories instead:
When running a Rust config without compiled Snowcap integration,
use the following directory instead (Lua users can use the same directory):
```sh
# Lua
just install run -- -c ./api/lua/examples/default_no_snowcap
# Rust
cargo run -- -c ./api/rust/examples/default_config_no_snowcap
```
Expand All @@ -205,8 +201,8 @@ Note that this currently copies default configs *with* Snowcap integration.
Run `cargo run -- config gen --help` for information on the command.
## More on configuration
Pinnacle is configured purely through IPC using [gRPC](https://grpc.io/). This is done through
configuration clients that use the [Lua](api/lua) and [Rust](api/rust) interface libraries.
Pinnacle is configured mostly at runtime through IPC using [gRPC](https://grpc.io/). This is done through
configuration clients that use the [Lua](api/lua) and [Rust](api/rust) APIs.
As the compositor has no direct integration with these clients, it must know what it needs to run
through a separate file, aptly called the `metaconfig.toml` file.
Expand All @@ -225,8 +221,8 @@ Rust config.
Additionally, if your config crashes, Pinnacle will also start the embedded Rust config.
> [!NOTE]
> If you have not run `eval $(luarocks path --lua-version <your-lua-version>)`, Pinnacle will fallback to the
> embedded Rust config.
> If you are using a Lua config and have not run `eval $(luarocks path --lua-version <your-lua-version>)`,
> Pinnacle will fallback to the embedded Rust config.
### The `metaconfig.toml` file
A `metaconfig.toml` file must contain the following entries:
Expand Down Expand Up @@ -255,26 +251,29 @@ Rust: https://pinnacle-comp.github.io/rust-reference/main.</b>
> Other branches for Lua soon<sup>tm</sup>

# Controls
> Yes, ctrl is a bad mod key I know, this will be changed to Awesome keybinds soon

The following are the default controls in the [`default_config`](api/rust/examples/default_config/main.rs).
| Binding | Action |
|----------------------------------------------|------------------------------------|
| <kbd>Ctrl</kbd> + <kbd>s</kbd> | Show the keybind overlay |
| <kbd>Ctrl</kbd> + <kbd>Mouse left drag</kbd> | Move window |
| <kbd>Ctrl</kbd> + <kbd>Mouse right drag</kbd>| Resize window |
| <kbd>Ctrl</kbd><kbd>Alt</kbd> + <kbd>q</kbd> | Quit Pinnacle |
| <kbd>Ctrl</kbd><kbd>Alt</kbd> + <kbd>c</kbd> | Close window |
| <kbd>Ctrl</kbd> + <kbd>Return</kbd> | Spawn [Alacritty](https://github.com/alacritty/alacritty) (you can change this in the config)|
| <kbd>Ctrl</kbd><kbd>Alt</kbd> + <kbd>Space</kbd> | Toggle between floating and tiled |
| <kbd>Ctrl</kbd> + <kbd>f</kbd> | Toggle fullscreen |
| <kbd>Ctrl</kbd> + <kbd>m</kbd> | Toggle maximized |
| <kbd>Ctrl</kbd> + <kbd>Space</kbd> | Cycle to the next layout |
| <kbd>Ctrl</kbd><kbd>Shift</kbd> + <kbd>Space</kbd> | Cycle to the previous layout |
| <kbd>Ctrl</kbd> + <kbd>1</kbd> to <kbd>5</kbd> | Switch to tag `1` to `5` |
| <kbd>Ctrl</kbd><kbd>Shift</kbd> + <kbd>1</kbd> to <kbd>5</kbd> | Toggle tag `1` to `5` |
| <kbd>Ctrl</kbd><kbd>Alt</kbd> + <kbd>1</kbd> to <kbd>5</kbd> | Move a window to tag `1` to `5` |
| <kbd>Ctrl</kbd><kbd>Alt</kbd><kbd>Shift</kbd> + <kbd>1</kbd> to <kbd>5</kbd> | Toggle tag `1` to `5` on a window |

The following are the default controls, mirroring Awesome's defaults.
<kbd>Mod</kbd> is <kbd>Super</kbd> when running in a tty and <kbd>Alt</kbd> when running as a nested window.
| Binding | Action |
|------------------------------------------------------------------------------|-----------------------------------|
| <kbd>Mod</kbd> + <kbd>s</kbd> | Show the keybind overlay |
| <kbd>Mod</kbd> + <kbd>Mouse left drag</kbd> | Move window |
| <kbd>Mod</kbd> + <kbd>Mouse right drag</kbd> | Resize window |
| <kbd>Mod</kbd><kbd>Shift</kbd> + <kbd>q</kbd> | Quit Pinnacle |
| <kbd>Mod</kbd><kbd>Ctrl</kbd> + <kbd>r</kbd> | Reload the config |
| <kbd>Mod</kbd><kbd>Shift</kbd> + <kbd>c</kbd> | Close window |
| <kbd>Mod</kbd> + <kbd>Return</kbd> | Spawn [Alacritty](https://github.com/alacritty/alacritty) (you can change this in the config) |
| <kbd>Mod</kbd><kbd>Ctrl</kbd> + <kbd>Space</kbd> | Toggle floating |
| <kbd>Mod</kbd> + <kbd>f</kbd> | Toggle fullscreen |
| <kbd>Mod</kbd> + <kbd>m</kbd> | Toggle maximized |
| <kbd>Mod</kbd> + <kbd>Space</kbd> | Cycle to the next layout |
| <kbd>Mod</kbd><kbd>Shift</kbd> + <kbd>Space</kbd> | Cycle to the previous layout |
| <kbd>Mod</kbd> + <kbd>1</kbd> to <kbd>5</kbd> | Switch to tag `1` to `5` |
| <kbd>Mod</kbd><kbd>Ctrl</kbd> + <kbd>1</kbd> to <kbd>5</kbd> | Toggle tag `1` to `5` |
| <kbd>Mod</kbd><kbd>Shift</kbd> + <kbd>1</kbd> to <kbd>5</kbd> | Move a window to tag `1` to `5` |
| <kbd>Mod</kbd><kbd>Ctrl</kbd><kbd>Shift</kbd> + <kbd>1</kbd> to <kbd>5</kbd> | Toggle tag `1` to `5` on a window |
# Feature Requests, Bug Reports, Contributions, and Questions
See [`CONTRIBUTING.md`](CONTRIBUTING.md).
Expand All @@ -283,4 +282,5 @@ See [`CONTRIBUTING.md`](CONTRIBUTING.md).
See [`CHANGELOG.md`](CHANGELOG.md).
# With Special Thanks To
- [Smithay](https://github.com/Smithay/smithay): For being a great compositor library and also allowing me not to deal with all the graphics stuff I still don't understand
- [Niri](https://github.com/YaLTeR/niri): For all that rendering and protocol stuff I, ahem, *took inspiration* from
65 changes: 40 additions & 25 deletions api/lua/examples/default/default_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ require("pinnacle").setup(function(Pinnacle)
local Util = Pinnacle.util
local Snowcap = Pinnacle.snowcap

-- `Snowcap` will be nil when the Snowcap API isn't installed or Snowcap isn't running
-- A normal installation of Pinnacle won't have this issue, so you can remove this cast if desired.
---@cast Snowcap +?

local key = Input.key

---@type Modifier
local mod_key = "ctrl"
local mod_key = "super"
-- Change the mod key to "alt" when running as a nested window
if Pinnacle.backend() == "window" then
mod_key = "alt"
end

local terminal = "alacritty"

Input.keybind({ mod_key }, "s", function()
Snowcap.integration.keybind_overlay():show()
end, {
group = "Compositor",
description = "Show the keybind overlay",
})

--------------------
-- Mousebinds --
--------------------
Expand All @@ -39,24 +40,38 @@ require("pinnacle").setup(function(Pinnacle)
-- Keybinds --
--------------------

-- mod_key + alt + q = Quit Pinnacle
Input.keybind({ mod_key, "alt" }, "q", function()
Snowcap.integration.quit_prompt():show()
-- mod_key + s shows the keybind overlay
if Snowcap then
Input.keybind({ mod_key }, "s", function()
Snowcap.integration.keybind_overlay():show()
end, {
group = "Compositor",
description = "Show the keybind overlay",
})
end

-- mod_key + shift + q = Quit Pinnacle
Input.keybind({ mod_key, "shift" }, "q", function()
if Snowcap then
Snowcap.integration.quit_prompt():show()
else
Pinnacle.quit()
end
end, {
group = "Compositor",
description = "Quit Pinnacle",
})

-- mod_key + alt + r = Reload config
Input.keybind({ mod_key, "alt" }, "r", function()
-- mod_key + ctrl + r = Reload config
Input.keybind({ mod_key, "ctrl" }, "r", function()
Pinnacle.reload_config()
end, {
group = "Compositor",
description = "Reload the config",
})

-- mod_key + alt + c = Close window
Input.keybind({ mod_key, "alt" }, "c", function()
-- mod_key + shift + c = Close window
Input.keybind({ mod_key, "shift" }, "c", function()
local focused = Window.get_focused()
if focused then
focused:close()
Expand All @@ -66,16 +81,16 @@ require("pinnacle").setup(function(Pinnacle)
description = "Close the focused window",
})

-- mod_key + alt + Return = Spawn `terminal`
-- mod_key + Return = Spawn `terminal`
Input.keybind({ mod_key }, key.Return, function()
Process.spawn(terminal)
end, {
group = "Process",
description = "Spawn `alacritty`",
})

-- mod_key + alt + space = Toggle floating
Input.keybind({ mod_key, "alt" }, key.space, function()
-- mod_key + ctrl + space = Toggle floating
Input.keybind({ mod_key, "ctrl" }, key.space, function()
local focused = Window.get_focused()
if focused then
focused:toggle_floating()
Expand Down Expand Up @@ -143,16 +158,16 @@ require("pinnacle").setup(function(Pinnacle)
description = "Switch to tag " .. tag_name,
})

-- mod_key + shift + 1-5 = Toggle tags 1-5
Input.keybind({ mod_key, "shift" }, tag_name, function()
-- mod_key + ctrl + 1-5 = Toggle tags 1-5
Input.keybind({ mod_key, "ctrl" }, tag_name, function()
Tag.get(tag_name):toggle_active()
end, {
group = "Tag",
description = "Toggle tag " .. tag_name,
})

-- mod_key + alt + 1-5 = Move window to tags 1-5
Input.keybind({ mod_key, "alt" }, tag_name, function()
-- mod_key + shift + 1-5 = Move window to tags 1-5
Input.keybind({ mod_key, "shift" }, tag_name, function()
local focused = Window.get_focused()
if focused then
focused:move_to_tag(Tag.get(tag_name) --[[@as TagHandle]])
Expand All @@ -162,8 +177,8 @@ require("pinnacle").setup(function(Pinnacle)
description = "Move the focused window to tag " .. tag_name,
})

-- mod_key + shift + alt + 1-5 = Toggle tags 1-5 on window
Input.keybind({ mod_key, "shift", "alt" }, tag_name, function()
-- mod_key + ctrl + shift + 1-5 = Toggle tags 1-5 on window
Input.keybind({ mod_key, "ctrl", "shift" }, tag_name, function()
local focused = Window.get_focused()
if focused then
focused:toggle_tag(Tag.get(tag_name) --[[@as TagHandle]])
Expand Down Expand Up @@ -317,7 +332,7 @@ require("pinnacle").setup(function(Pinnacle)
end,
})

-- Request all windows to use client-side decorations
-- Request all windows use client-side decorations
Window.add_window_rule({
cond = {
all = {},
Expand Down
10 changes: 0 additions & 10 deletions api/lua/examples/default_no_snowcap/.luarc.json

This file was deleted.

Loading

0 comments on commit 503cc06

Please sign in to comment.