Skip to content

Commit 7f36731

Browse files
committed
add-clipboard-widget
1 parent f24bd17 commit 7f36731

4 files changed

Lines changed: 807 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ https://github.com/user-attachments/assets/aab8d8e8-248f-46a1-919c-9b0601236ac1
9494
- **[Cava](https://github.com/amnweb/yasb/wiki/(Widget)-Cava)**: Displays audio visualizer using Cava.
9595
- **[Copilot](https://github.com/amnweb/yasb/wiki/(Widget)-Copilot)**: GitHub Copilot usage with a detailed menu showing statistics
9696
- **[CPU](https://github.com/amnweb/yasb/wiki/(Widget)-CPU)**: Shows the current CPU usage.
97+
- **[Clipboard](https://github.com/amnweb/yasb/wiki/(Widget)-Clipboard)**: A native lightweight clipboard manager for YASB.
9798
- **[Clock](https://github.com/amnweb/yasb/wiki/(Widget)-Clock)**: Displays the current time and date.
9899
- **[Custom](https://github.com/amnweb/yasb/wiki/(Widget)-Custom)**: Create a custom widget.
99100
- **[Github](https://github.com/amnweb/yasb/wiki/(Widget)-Github)**: Shows notifications from GitHub.

docs/widgets/(Widget)-Clipboard.md

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
# Clipboard Widget for YASB
2+
3+
A lightweight clipboard manager for YASB that integrates directly with the native Windows Clipboard History (Win + V). This widget provides real-time access to your system's clip buffer without the need for heavy local storage or complex background monitoring.
4+
5+
## Features
6+
- **Native Windows Sync**: Syncs in real-time with your official Windows Clipboard History.
7+
- **Search**: Built-in real-time search bar to filter through your text-based history.
8+
- **History**: View your Clipboard history and delete a single history item or your entire history.
9+
- **Image Support**: Full support for re-copying images directly from the history list.
10+
- **Long text preview**: Hover over a copied long piece of text to display text preview (configurable).
11+
- **Image list info**: Show image dimensions, size, and date in the history list (configurable).
12+
- **Feedback**: Visual feedback when content is copied.
13+
- **Customizable tooltips**: Enable/disable tooltips and adjust delay.
14+
15+
## Options
16+
17+
| Option | Type | Default | Description |
18+
| :--- | :--- | :--- | :--- |
19+
| `type` | `string` | `yasb.clipboard.ClipboardWidget` | The widget class identifier. |
20+
| `label` | `string` | `<span>\udb80\udd4d</span>` | Primary label format. |
21+
| `label_alt` | `string` | `CLIPBOARD` | Alternative label format (swapped on right-click). |
22+
| `max_history` | `integer` | `50` | Maximum number of history items to fetch from Windows. |
23+
| `class_name` | `string` | `""` | Additional CSS class for the widget container. |
24+
| `copied_feedback` | `string` | `\uf00c` | Feedback message when copying. |
25+
| `menu` | `dict` | (See Schema) | Configuration for the popup menu. |
26+
| `icons` | `dict` | (See Schema) | Custom icons for clipboard actions. |
27+
| `animation` | `dict` | (See Schema) | Animation configuration for label toggling. |
28+
| `label_shadow` | `dict` | (See Schema) | Shadow configuration for the label. |
29+
| `container_shadow` | `dict` | (See Schema) | Shadow configuration for the widget container. |
30+
31+
## Icons Configuration Defaults
32+
33+
| Key | Default | Description |
34+
| :--- | :--- | :--- |
35+
| `clear_icon` | `\uf1f8` | Clear all history icon. |
36+
| `delete_icon` | `\uf1f8` | Delete item icon. |
37+
38+
## Menu Configuration Defaults
39+
40+
| Key | Default | Description |
41+
| :--- | :--- | :--- |
42+
| `blur` | `true` | Enable blur effect on popup. |
43+
| `round_corners` | `true` | Enable rounded corners on popup. |
44+
| `round_corners_type` | `"normal"` | Corner radius style (`"normal"` or `"small"`). |
45+
| `border_color` | `"System"` | Border color for the popup. |
46+
| `alignment` | `"right"` | Horizontal alignment relative to widget (`"left"`, `"right"`, `"center"`). |
47+
| `direction` | `"down"` | Vertical direction for popup (`"up"` or `"down"`). |
48+
| `offset_top` | `6` | Top offset in pixels. |
49+
| `offset_left` | `0` | Left offset in pixels. |
50+
| `max_item_length` | `50` | Max characters to display for text items (10-200). |
51+
| `tooltip_enabled` | `true` | Enable custom tooltips for history items. |
52+
| `tooltip_delay` | `400` | Delay in milliseconds before showing tooltip (0-2000). |
53+
| `show_image_thumbnail` | `true` | Show image thumbnail in history list. If false, shows `image_replacement_text` instead. |
54+
| `image_replacement_text` | `"[Image]"` | Text to display for image items in history list when `show_image_thumbnail` is false. |
55+
| `show_image_list_info` | `true` | Show image dimensions, date, and size below the image in the history list. |
56+
57+
## Callbacks
58+
59+
| Function | Description |
60+
| :--- | :--- |
61+
| `toggle_menu` | Opens/closes the clipboard history popup (Scheduled asynchronously). |
62+
| `toggle_label` | Switches display between `label` and `label_alt` on the bar. |
63+
64+
---
65+
66+
67+
## Configuration Example
68+
69+
```yaml
70+
71+
clipboard:
72+
type: "yasb.clipboard.ClipboardWidget"
73+
options:
74+
label: "<span>\uf0ea</span>"
75+
label_alt: "<span>CLIPBOARD</span>"
76+
icons:
77+
delete_icon: "\uf1f8"
78+
clear_icon: "\uf1f8"
79+
copied_feedback: "\uf00c"
80+
menu:
81+
blur: true
82+
round_corners: true
83+
alignment: "right"
84+
direction: "down"
85+
tooltip_enabled: true
86+
tooltip_delay: 400
87+
show_image_thumbnail: true
88+
image_replacement_text: "[IMAGE]"
89+
show_image_list_info: true
90+
callbacks:
91+
on_left: "toggle_menu"
92+
on_right: "toggle_label"
93+
```
94+
95+
## Styling
96+
97+
### Available CSS Classes
98+
99+
| Class | Description |
100+
| :--- | :--- |
101+
| `.clipboard-widget` | Main widget container on the bar |
102+
| `.widget-container` | Inner container for widget content |
103+
| `.label` | Primary label/icon on the bar |
104+
| `.clipboard-menu` | Main popup container |
105+
| `.search-input` | Search bar input field |
106+
| `.clear-button` | Clear all history button |
107+
| `.scroll-area` | Scroll area container |
108+
| `.clipboard-scroll-content` | Content container inside scroll area |
109+
| `.clipboard-item` | Individual clipboard item container |
110+
| `.clipboard-item-content` | Content area (button + optional info) |
111+
| `.clipboard-item-btn` | Clickable button for each item |
112+
| `.clipboard-item-info` | Image info container (dimensions, size, date) |
113+
| `.image-list-info` | Labels for image metadata |
114+
| `.delete-button` | Delete item button |
115+
116+
### Example CSS
117+
118+
```css
119+
/* Widget on the bar */
120+
.clipboard-widget {
121+
font-family: "JetBrainsMono Nerd Font", "Segoe UI Variable";
122+
}
123+
124+
/* Widget Label (icon/text on bar) */
125+
.clipboard-widget .label {
126+
color: #ffffff;
127+
}
128+
129+
/* Main Popup Container */
130+
.clipboard-menu {
131+
background-color: #1e1e2e;
132+
border: 1px solid #11111b;
133+
border-radius: 10px;
134+
padding: 8px;
135+
}
136+
137+
/* Search Bar */
138+
.clipboard-menu .search-input {
139+
background-color: rgba(255, 255, 255, 0.05);
140+
border: 1px solid rgba(255, 255, 255, 0.1);
141+
border-radius: 6px;
142+
padding: 6px 10px;
143+
margin-bottom: 6px;
144+
color: #cdd6f4;
145+
font-size: 13px;
146+
}
147+
148+
.clipboard-menu .search-input:focus {
149+
border: 1px solid #89b4fa;
150+
}
151+
152+
/* Global Clear Button */
153+
.clipboard-menu .clear-button {
154+
background-color: #cb3b42;
155+
border-radius: 6px;
156+
padding: 5px;
157+
margin-bottom: 8px;
158+
font-weight: bold;
159+
font-size: 11px;
160+
}
161+
162+
.clipboard-menu .clear-button:hover {
163+
background-color: #cc6a6f;
164+
}
165+
166+
/* Scroll Area */
167+
.clipboard-menu .scroll-area {
168+
background: transparent;
169+
}
170+
171+
/* Scroll Content Container */
172+
.clipboard-menu .clipboard-scroll-content {
173+
background: transparent;
174+
}
175+
176+
/* Clipboard Item Container */
177+
.clipboard-menu .clipboard-item {
178+
background-color: rgba(255, 255, 255, 0.03);
179+
border-radius: 6px;
180+
margin-bottom: 4px;
181+
padding: 4px 8px;
182+
font-size: 12px;
183+
}
184+
185+
.clipboard-menu .clipboard-item:hover {
186+
background-color: rgba(255, 255, 255, 0.08);
187+
border: 1px solid #11111b;
188+
}
189+
190+
/* Content Area (button + optional info) */
191+
.clipboard-menu .clipboard-item-content {
192+
background: transparent;
193+
}
194+
195+
/* Item Button */
196+
.clipboard-menu .clipboard-item-btn {
197+
background: transparent;
198+
border: none;
199+
text-align: left;
200+
padding: 4px;
201+
}
202+
203+
/* Image Info Container */
204+
.clipboard-menu .clipboard-item-info {
205+
background: transparent;
206+
}
207+
208+
/* Image List Info (dimensions, size, date) */
209+
.clipboard-menu .image-list-info {
210+
font-size: 10px;
211+
color: #ffffff;
212+
padding-left: 4px;
213+
}
214+
215+
/* Delete Button */
216+
.clipboard-menu .delete-button {
217+
background: #cb3b42;
218+
border: none;
219+
padding: 4px;
220+
}
221+
222+
.clipboard-menu .delete-button:hover {
223+
background-color: #cc6a6f;
224+
}
225+
```
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
from typing import Literal
2+
3+
from pydantic import Field
4+
5+
from core.validation.widgets.base_model import (
6+
AnimationConfig,
7+
CallbacksConfig,
8+
CustomBaseModel,
9+
KeybindingConfig,
10+
ShadowConfig,
11+
)
12+
13+
14+
class ClipboardMenuConfig(CustomBaseModel):
15+
"""Configuration for the clipboard popup menu."""
16+
17+
blur: bool = True
18+
round_corners: bool = True
19+
round_corners_type: Literal["normal", "small"] = "normal"
20+
border_color: str = "System"
21+
alignment: Literal["left", "right", "center"] = "right"
22+
direction: Literal["up", "down"] = "down"
23+
offset_top: int = 6
24+
offset_left: int = 0
25+
max_item_length: int = Field(default=50, ge=10, le=200)
26+
tooltip_enabled: bool = True
27+
tooltip_delay: int = Field(default=400, ge=0, le=2000)
28+
show_image_thumbnail: bool = True
29+
image_replacement_text: str = "[Image]"
30+
show_image_list_info: bool = True
31+
32+
33+
class ClipboardIconsConfig(CustomBaseModel):
34+
"""Configuration for clipboard widget icons."""
35+
36+
clear_icon: str = "\uf1f8"
37+
delete_icon: str = "\uf1f8"
38+
39+
40+
class ClipboardCallbacksConfig(CallbacksConfig):
41+
"""Callbacks configuration with clipboard-specific defaults."""
42+
43+
on_left: str = "toggle_menu"
44+
on_right: str = "toggle_label"
45+
46+
47+
class ClipboardConfig(CustomBaseModel):
48+
"""Main configuration model for the Clipboard widget."""
49+
50+
label: str = "<span>\udb80\udd4d</span>"
51+
label_alt: str = "CLIPBOARD"
52+
class_name: str = ""
53+
copied_feedback: str = "\uf00c"
54+
max_history: int = Field(default=50, ge=10, le=500)
55+
menu: ClipboardMenuConfig = ClipboardMenuConfig()
56+
icons: ClipboardIconsConfig = ClipboardIconsConfig()
57+
animation: AnimationConfig = AnimationConfig()
58+
label_shadow: ShadowConfig = ShadowConfig()
59+
container_shadow: ShadowConfig = ShadowConfig()
60+
keybindings: list[KeybindingConfig] = []
61+
callbacks: ClipboardCallbacksConfig = ClipboardCallbacksConfig()

0 commit comments

Comments
 (0)