This commit is contained in:
sankalp committed 2025-02-07 12:50:50 +05:45
1 parent 4b21fa5d53
commit c80ce028e4
8 files changed
+17 -276

No files matched your search

@@ -7,3 +7,4 @@ from .power import *
from .sh import *
from .todo import *
from .wallpapers import *
# from .window_switcher import *
@@ -98,14 +98,19 @@ class BluetoothConnections(Box):
self.children = [
CenterBox(
name="bluetooth-header",
start_children=self.scan_button,
center_children=Label(name="bluetooth-text", label="Bluetooth Devices"),
end_children=self.toggle_button,
),
Label(name="bluetooth-text", label="Paired"),
ScrolledWindow(min_content_size=(-1, -1), child=self.paired_box),
Label(name="bluetooth-text", label="Available"),
ScrolledWindow(min_content_size=(-1, -1), child=self.available_box),
Label(name="bluetooth-section", label="Paired"),
ScrolledWindow(
name="bluetooth-paired", v_expand=True, child=self.paired_box
),
Label(name="bluetooth-section", label="Available"),
ScrolledWindow(
name="bluetooth-paired", v_expand=True, child=self.available_box
),
]
# to run notify closures thus display the status
@@ -121,4 +126,3 @@ class BluetoothConnections(Box):
if device.paired:
return self.paired_box.add(slot)
return self.available_box.add(slot)
@@ -59,16 +59,15 @@ class Cliphist(Box):
def on_button_clicked(self, *_):
GLib.spawn_command_line_async("cliphist wipe")
self.cliphist_manager.update_cliphist_history()
def open_launcher(self):
"""Opens the clipboard history launcher."""
if not self.viewport:
self.viewport = Box(name="viewport", spacing=4, orientation="v")
self.scrolled_window = ScrolledWindow(
name="scrolled-window",
name="cliphist-history",
spacing=10,
h_scrollbar_policy="never",
v_scrollbar_policy="never",
child=self.viewport,
)
self.launcher_box.add(self.scrolled_window)
@@ -80,11 +79,9 @@ class Cliphist(Box):
self.search_entry.grab_focus()
def close_launcher(self):
"""Closes the clipboard history launcher and clears viewport."""
self.launcher.close()
def handle_search_input(self, text: str):
"""Handles search input to filter clipboard history."""
self.cliphist_manager.arrange_viewport(text)
@@ -100,7 +97,6 @@ class CliphistManager:
)
def get_clip_history(self) -> List[dict]:
"""Fetches the entire clipboard history from cliphist."""
try:
result = subprocess.run(
["cliphist", "list"], capture_output=True, text=True, check=True
@@ -111,7 +107,6 @@ class CliphistManager:
return []
def _parse_clip_history(self, output: str) -> List[dict]:
"""Parses the clipboard history output from cliphist."""
items = []
for line in output.splitlines():
if line.strip():
@@ -121,7 +116,6 @@ class CliphistManager:
return items
def copy_clip(self, clip_id: str):
"""Copies a clipboard item using cliphist and closes the launcher."""
try:
decode_result = subprocess.run(
["cliphist", "decode", clip_id], capture_output=True, check=True
@@ -132,7 +126,6 @@ class CliphistManager:
print(f"Error copying clip {clip_id}: {e}")
def save_image_file(self, clip_id: str) -> str:
"""Saves image clips as files in /tmp and returns the file path."""
output_file = f"/tmp/cliphist-{clip_id}.png"
os.makedirs("/tmp", exist_ok=True)
@@ -150,24 +143,19 @@ class CliphistManager:
return ""
def query_clips(self, query: str = "") -> List[dict]:
"""Filters clipboard history based on the search query."""
history = self.get_clip_history()
if not query.strip():
return history[:16]
return history
return [item for item in history if query.lower() in item["content"].lower()][
:16
]
return [item for item in history if query.lower() in item["content"].lower()]
def bake_clip_slot(self, item: dict) -> Button:
"""Creates a button slot for each clipboard entry."""
if "[[ binary data" in item["content"].lower():
return self._create_image_button(item)
return self._create_text_button(item)
def _create_image_button(self, item: dict) -> Button:
"""Creates a button for image clips with a background image."""
output_file = self.save_image_file(item["id"])
if output_file and os.path.exists(output_file):
button = Button(
@@ -184,7 +172,6 @@ class CliphistManager:
return None
def _create_text_button(self, item: dict) -> Button:
"""Creates a button for text clips."""
return Button(
child=Label(
label=item["content"][:55]
@@ -198,13 +185,11 @@ class CliphistManager:
)
def update_cliphist_history(self):
"""Updates the clipboard history when a new item is copied."""
self.cliphist_history = self.get_clip_history()
if self.launcher.viewport:
GLib.idle_add(self.arrange_viewport)
def arrange_viewport(self, query: str = ""):
"""Arranges the viewport based on the search query."""
if not self.launcher.viewport:
return
@@ -1,242 +0,0 @@
from fabric.widgets.box import Box
from fabric.widgets.button import Button
from fabric.widgets.label import Label
from snippets import MaterialIcon
class Buttons(Box):
def __init__(self, **kwargs):
super().__init__(
name="buttons",
spacing=4,
h_align="center",
v_align="start",
h_expand=True,
v_expand=True,
visible=True,
all_visible=True,
)
self.network_status_button = Button(
name="network-status-button",
h_expand=True,
child=Box(
h_align="start",
v_align="center",
spacing=10,
children=[
MaterialIcon("wifi"),
Box(
name="network-text",
orientation="v",
h_align="start",
v_align="center",
children=[
Box(
children=[
Label(
name="network-label",
label="Wi-Fi",
justification="left",
),
Box(h_expand=True),
]
),
Box(
children=[
Label(
name="network-ssid",
label="ARGOS_5GHz",
justification="left",
),
Box(h_expand=True),
]
),
],
),
],
),
)
self.network_menu_button = Button(
name="network-menu-button",
child=MaterialIcon("chevron_right"),
)
self.network_button = Box(
name="network-button",
orientation="h",
h_align="fill",
v_align="center",
h_expand=True,
v_expand=True,
children=[
self.network_status_button,
self.network_menu_button,
],
)
self.bluetooth_status_button = Button(
name="bluetooth-status-button",
h_expand=True,
child=Box(
h_align="start",
v_align="center",
spacing=10,
children=[
MaterialIcon("bluetooth"),
Box(
name="bluetooth-text",
orientation="v",
h_align="start",
v_align="center",
children=[
Box(
children=[
Label(
name="bluetooth-label",
label="Bluetooth",
justification="left",
),
Box(h_expand=True),
]
),
Box(
children=[
Label(
name="bluetooth-status",
label="Connected",
justification="left",
),
Box(h_expand=True),
]
),
],
),
],
),
)
self.bluetooth_menu_button = Button(
name="bluetooth-menu-button",
child=MaterialIcon("chevron_right"),
)
self.bluetooth_button = Box(
name="bluetooth-button",
orientation="h",
h_align="fill",
v_align="center",
h_expand=True,
v_expand=True,
children=[
self.bluetooth_status_button,
self.bluetooth_menu_button,
],
)
self.night_mode_button = Button(
name="night-mode-button",
child=Box(
h_align="start",
v_align="center",
spacing=10,
children=[
MaterialIcon("nightlight"),
Box(
name="night-mode-text",
orientation="v",
h_align="start",
v_align="center",
children=[
Box(
children=[
Label(
name="night-mode-label",
label="Night Mode",
justification="left",
),
Box(h_expand=True),
]
),
Box(
children=[
Label(
name="night-mode-status",
label="Enabled",
justification="left",
),
Box(h_expand=True),
]
),
],
),
],
),
)
self.caffeine_button = Button(
name="caffeine-button",
child=Box(
h_align="start",
v_align="center",
spacing=10,
children=[
MaterialIcon("coffee"),
Box(
name="caffeine-text",
orientation="v",
h_align="start",
v_align="center",
children=[
Box(
children=[
Label(
name="caffeine-label",
label="Caffeine",
justification="left",
),
Box(h_expand=True),
]
),
Box(
children=[
Label(
name="caffeine-status",
label="Enabled",
justification="left",
),
Box(h_expand=True),
]
),
],
),
],
),
)
self.add(self.network_button)
self.add(self.bluetooth_button)
self.add(self.night_mode_button)
self.add(self.caffeine_button)
self.show_all()
class Dashboard(Box):
def __init__(self, **kwargs):
super().__init__(
name="dashboard",
h_align="center",
v_align="start",
h_expand=True,
v_expand=True,
visible=True,
all_visible=True,
)
self.buttons = Buttons()
self.add(self.buttons)
self.show_all()
@@ -80,7 +80,7 @@ class Emoji(Box):
class EmojiManager:
def __init__(self, launcher):
self.launcher = launcher
self.emoji_file_path = os.path.expanduser("~/dotfiles/modus/assets/emoji.json")
self.emoji_file_path = os.path.expanduser("~/modus/assets/emoji.json")
def load_emojis(self) -> Generator[tuple, None, None]:
if not os.path.exists(self.emoji_file_path):
@@ -1,7 +1,6 @@
import os
import subprocess
from typing import List
from gi.repository import GLib
from fabric.widgets.box import Box
from fabric.widgets.button import Button
from fabric.widgets.entry import Entry
@@ -54,7 +53,6 @@ class Sh(Box):
if not self.viewport:
self.viewport = Box(name="viewport", spacing=10, orientation="v")
self.scrolled_window = ScrolledWindow(
name="scrolled-window",
spacing=10,
h_scrollbar_policy="never",
v_scrollbar_policy="never",
@@ -6,7 +6,6 @@ from fabric.widgets.button import Button
from fabric.widgets.entry import Entry
from fabric.widgets.label import Label
from fabric.widgets.scrolledwindow import ScrolledWindow
from gi.repository import GLib
from snippets import MaterialIcon
@@ -60,10 +59,9 @@ class TodoManager(Box):
if not self.viewport:
self.viewport = Box(name="viewport", spacing=4, orientation="v")
self.scrolled_window = ScrolledWindow(
name="scrolled-window",
name="todo-content",
spacing=10,
h_scrollbar_policy="never",
v_scrollbar_policy="never",
child=self.viewport,
)
self.launcher_box.add(self.scrolled_window)
+1 -4
View File
@@ -37,7 +37,7 @@ class Launcher(Window):
v_expand=True,
h_expand=True,
transition_type="crossfade",
transition_duration=250,
transition_duration=100,
children=[
self.launcher,
self.wallpapers,
@@ -122,9 +122,6 @@ class Launcher(Window):
self.stack.set_visible_child(widgets[widget])
widgets[widget].show()
# if widget != "launcher":
# self.launcher.hide()
if widget != "wallpapers":
self.wallpapers.viewport.hide()
self.wallpapers.viewport.set_property("name", None)