Skip to content

Commit

Permalink
feat: new clipboard manager module
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeStanger committed Feb 26, 2023
1 parent 5bbe64b commit 575d6cc
Show file tree
Hide file tree
Showing 26 changed files with 1,809 additions and 149 deletions.
43 changes: 29 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ description = "Customisable GTK Layer Shell wlroots/sway bar"
default = [
"http",
"config+all",
"clipboard",
"clock",
"music+all",
"sys_info",
Expand All @@ -24,6 +25,8 @@ http = ["dep:reqwest"]
"config+toml" = ["toml"]
"config+corn" = ["libcorn"]

clipboard = ["nix"]

clock = ["chrono"]

music = ["regex"]
Expand Down Expand Up @@ -60,6 +63,7 @@ notify = { version = "5.0.0", default-features = false }
wayland-client = "0.29.5"
wayland-protocols = { version = "0.29.5", features = ["unstable_protocols", "client"] }
smithay-client-toolkit = { version = "0.16.0", default-features = false, features = ["calloop"] }

lazy_static = "1.4.0"
async_once = "0.2.6"
cfg-if = "1.0.0"
Expand All @@ -73,6 +77,9 @@ serde_yaml = { version = "0.9.4", optional = true }
toml = { version = "0.7.0", optional = true }
libcorn = { version = "0.6.1", optional = true }

# clipboard
nix = { version = "0.26.2", optional = true }

# clock
chrono = { version = "0.4.19", optional = true }

Expand All @@ -92,4 +99,4 @@ hyprland = { version = "0.3.0", optional = true }
futures-util = { version = "0.3.21", optional = true }

# shared
regex = { version = "1.6.0", default-features = false, features = ["std"], optional = true } # music, sys_info
regex = { version = "1.6.0", default-features = false, features = ["std"], optional = true } # music, sys_info
1 change: 1 addition & 0 deletions docs/Compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ cargo build --release --no-default-features \
| config+toml | Enables configuration support for TOML. |
| config+corn | Enables configuration support for [Corn](https://github.com/jakestanger.corn). |
| **Modules** | |
| clipboard | Enables the `clipboard` module. |
| clock | Enables the `clock` module. |
| music+all | Enables the `music` module with support for all player types. |
| music+mpris | Enables the `music` module with MPRIS support. |
Expand Down
93 changes: 93 additions & 0 deletions docs/modules/Clipboard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Shows recent clipboard items, allowing you to switch between them to re-copy previous values.
Clicking the icon button opens the popup containing all functionality.

Supports plain text and images.

![Screenshot of clipboard popup open, with two textual values and an image copied. Several other unrelated widgets are visible on the bar.](https://f.jstanger.dev/github/ironbar/clipboard.png?raw)

## Configuration

> Type: `clipboard`
| Name | Type | Default | Description |
|-----------------------|---------------------------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| `icon` | `string/image` | `󰨸` | Icon to show on the widget button. |
| `max_items` | `integer` | `10` | Maximum number of items to show on the bar. |
| `truncate` | `start` or `middle` or `end` or `Map` | `null` | The location of the ellipses and where to truncate text from. Leave null to avoid truncating. Use the long-hand `Map` version if specifying a length. |
| `truncate.mode` | `start` or `middle` or `end` | `null` | The location of the ellipses and where to truncate text from. Leave null to avoid truncating. |
| `truncate.length` | `integer` | `null` | The fixed width (in chars) of the widget. Leave blank to let GTK automatically handle. |
| `truncate.max_length` | `integer` | `null` | The maximum number of characters before truncating. Leave blank to let GTK automatically handle. |

See [here](images) for information on images.

<details>
<summary>JSON</summary>

```json
{
"end": {
"type": "clipboard",
"max_items": 3,
"truncate": {
"mode": "end",
"length": 50
}
}
}
```
</details>

<details>
<summary>TOML</summary>

```toml
[[end]]
type = "clipboard"
max_items = 3

[[end.truncate]]
mode = "end"
length = 50
```
</details>

<details>
<summary>YAML</summary>

```yaml
end:
- type: 'clipboard'
max_items: 3
truncate:
mode: 'end'
length: 50
```
</details>
<details>
<summary>Corn</summary>
```corn
{
end = [ {
type = "clipboard"
max_items = 3
truncate.mode = "end"
truncate.length = 50
} ]
}
```
</details>

## Styling

| Selector | Description |
|--------------------------------------|------------------------------------------------------|
| `#clipboard` | Clipboard widget. |
| `#clipboard .btn` | Clipboard widget button. |
| `#popup-clipboard` | Clipboard popup box. |
| `#popup-clipboard .item` | Clipboard row item inside the popup. |
| `#popup-clipboard .item .btn` | Clipboard row item radio button. |
| `#popup-clipboard .item .btn.text` | Clipboard row item radio button (text values only). |
| `#popup-clipboard .item .btn.image` | Clipboard row item radio button (image values only). |
| `#popup-clipboard .item .btn-remove` | Clipboard row item remove button. |
25 changes: 20 additions & 5 deletions examples/config.corn
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ let {
show_icons = true
}

$mpd_local = { type = "mpd" music_dir = "/home/jake/Music" }
$mpd_server = { type = "mpd" host = "chloe:6600" }
$mpris = {
type = "music"
player_type = "mpris"

on_click_middle = "playerctl play-pause"
on_scroll_up = "playerctl volume +5"
on_scroll_down = "playerctl volume -5"

}

$mpd_local = { type = "music" player_type = "mpd" music_dir = "/home/jake/Music" truncate.mode = "end" truncate.max_length = 100 }
$mpd_server = { type = "music" player_type = "mpd" host = "chloe:6600" truncate = "end" }

$sys_info = {
type = "sys_info"
Expand Down Expand Up @@ -55,6 +65,8 @@ let {
show_if.interval = 500
}

$clipboard = { type = "clipboard" max_items = 3 truncate.mode = "end" truncate.length = 50 }

// -- begin custom --
$button = { type = "button" name="power-btn" label = "" on_click = "popup:toggle" }

Expand Down Expand Up @@ -86,10 +98,13 @@ let {
// -- end custom --

$left = [ $workspaces $launcher ]
$right = [ $mpd_local $mpd_server $phone_battery $sys_info $power_menu $clock ]
$right = [ $mpd_local $mpd_server $phone_battery $sys_info $clipboard $power_menu $clock ]
}
in {
anchor_to_edges = true
position = "top"
start = $left end = $right
position = "bottom"
icon_theme = "Paper"

start = $left
end = $right
}
20 changes: 9 additions & 11 deletions examples/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"music_dir": "/home/jake/Music",
"player_type": "mpd",
"truncate": {
"length": 100,
"max_length": 100,
"mode": "end"
},
"type": "music"
Expand Down Expand Up @@ -43,6 +43,14 @@
},
"type": "sys_info"
},
{
"max_items": 3,
"truncate": {
"length": 50,
"mode": "end"
},
"type": "clipboard"
},
{
"bar": [
{
Expand Down Expand Up @@ -98,16 +106,6 @@
"icon_theme": "Paper",
"position": "bottom",
"start": [
{
"bar": [
{
"size": 32,
"src": "file:///path/to/image.jpg",
"type": "image"
}
],
"type": "custom"
},
{
"all_monitors": false,
"name_map": {
Expand Down
18 changes: 9 additions & 9 deletions examples/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ player_type = 'mpd'
type = 'music'

[end.truncate]
length = 100
max_length = 100
mode = 'end'

[[end]]
Expand Down Expand Up @@ -44,6 +44,14 @@ memory = 30
networks = 3
temps = 5

[[end]]
max_items = 3
type = 'clipboard'

[end.truncate]
length = 50
mode = 'end'

[[end]]
class = 'power-menu'
tooltip = '''Up: {{30000:uptime -p | cut -d ' ' -f2-}}'''
Expand Down Expand Up @@ -87,14 +95,6 @@ type = 'label'
[[end]]
type = 'clock'

[[start]]
type = 'custom'

[[start.bar]]
size = 32
src = 'file:///path/to/image.jpg'
type = 'image'

[[start]]
all_monitors = false
type = 'workspaces'
Expand Down
Loading

0 comments on commit 575d6cc

Please sign in to comment.