Save
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
from ignis.widgets import Widget
|
||||
from .workspaces import workspaces
|
||||
from .kb_layout import kb_layout
|
||||
from .clock import clock
|
||||
from .pinned_apps import pinned_apps
|
||||
from .tray import tray
|
||||
from .battery import battery_widget
|
||||
# from .wallpaper_engine import wallpaper_engine_widget
|
||||
|
||||
def bar(monitor: int) -> Widget.Window:
|
||||
return Widget.Window(
|
||||
anchor=["left", "top", "right"],
|
||||
exclusivity="exclusive",
|
||||
monitor=monitor,
|
||||
namespace=f"ignis_BAR_{monitor}",
|
||||
layer="top",
|
||||
kb_mode="none",
|
||||
child=Widget.CenterBox(
|
||||
css_classes=["bar-widget"],
|
||||
start_widget=Widget.Box(child=[workspaces()]),
|
||||
center_widget=Widget.Box(child=[pinned_apps()]),
|
||||
end_widget=Widget.Box(child=[tray(), kb_layout(), battery_widget(), clock(monitor)]),
|
||||
), # wallpaper_engine_widget(),
|
||||
css_classes=["unset"],
|
||||
)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,35 @@
|
||||
from ignis.widgets import Widget
|
||||
from ignis.services.upower import UPowerService, UPowerDevice
|
||||
|
||||
upower = UPowerService.get_default()
|
||||
|
||||
|
||||
def battery_item(device: UPowerDevice) -> Widget.Box:
|
||||
return Widget.Box(
|
||||
css_classes=["battery-item"],
|
||||
setup=lambda self: device.connect("removed", lambda x: self.unparent()),
|
||||
child=[
|
||||
Widget.Icon(
|
||||
icon_name=device.bind("icon_name"), css_classes=["battery-icon"]
|
||||
),
|
||||
Widget.Label(
|
||||
label=device.bind("percent", lambda x: f"{int(x)}%"),
|
||||
css_classes=["battery-percent"],
|
||||
),
|
||||
Widget.Scale(
|
||||
min=0,
|
||||
max=100,
|
||||
value=device.bind("percent"),
|
||||
sensitive=False,
|
||||
css_classes=["battery-scale"],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def battery_widget() -> Widget.Box:
|
||||
return Widget.Box(
|
||||
setup=lambda self: upower.connect(
|
||||
"battery-added", lambda x, device: self.append(battery_item(device))
|
||||
),
|
||||
)
|
||||
@@ -0,0 +1,41 @@
|
||||
import datetime
|
||||
from ignis.widgets import Widget
|
||||
from ignis.app import IgnisApp
|
||||
from ignis.utils import Utils
|
||||
from ignis.variable import Variable
|
||||
from .indicator import status_icons
|
||||
|
||||
app = IgnisApp.get_default()
|
||||
|
||||
current_time = Variable(
|
||||
value=Utils.Poll(1000, lambda x: datetime.datetime.now().strftime("%H:%M:%S")).bind(
|
||||
"output"
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def clock(monitor):
|
||||
window: Widget.Window = app.get_window("ignis_CONTROL_CENTER") # type: ignore
|
||||
|
||||
def on_click(x):
|
||||
if window.monitor == monitor:
|
||||
window.visible = not window.visible
|
||||
else:
|
||||
window.set_monitor(monitor)
|
||||
window.visible = True
|
||||
|
||||
return Widget.Button(
|
||||
child=Widget.Box(
|
||||
child=[
|
||||
status_icons(),
|
||||
Widget.Label(
|
||||
label=current_time.bind("value"),
|
||||
),
|
||||
]
|
||||
),
|
||||
css_classes=window.bind(
|
||||
"visible",
|
||||
lambda value: ["clock", "unset", "active"] if value else ["clock", "unset"],
|
||||
),
|
||||
on_click=on_click,
|
||||
)
|
||||
@@ -0,0 +1,92 @@
|
||||
from ignis.widgets import Widget
|
||||
from ignis.services.network import NetworkService
|
||||
from ignis.services.notifications import NotificationService
|
||||
from ignis.services.recorder import RecorderService
|
||||
from ignis.services.audio import AudioService
|
||||
|
||||
network = NetworkService.get_default()
|
||||
notifications = NotificationService.get_default()
|
||||
recorder = RecorderService.get_default()
|
||||
audio = AudioService.get_default()
|
||||
|
||||
|
||||
def indicator_icon(**kwargs):
|
||||
return Widget.Icon(style="margin-right: 0.5rem;", css_classes=["unset"], **kwargs)
|
||||
|
||||
|
||||
def wifi_icon():
|
||||
def check_visible(*args) -> bool:
|
||||
if len(network.wifi.devices) > 0:
|
||||
if network.ethernet.is_connected:
|
||||
if network.wifi.is_connected:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
icon = indicator_icon(image=network.wifi.bind("icon-name"))
|
||||
icon.visible = network.wifi.bind("devices", check_visible)
|
||||
icon.visible = network.ethernet.bind("is_connected", check_visible)
|
||||
icon.visible = network.wifi.bind("is_connected", check_visible)
|
||||
return icon
|
||||
|
||||
|
||||
def ethernet_icon():
|
||||
def check_visible(*args) -> bool:
|
||||
if len(network.ethernet.devices) > 0:
|
||||
if network.wifi.is_connected:
|
||||
if network.ethernet.is_connected:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
icon = indicator_icon(image=network.ethernet.bind("icon_name"))
|
||||
icon.visible = network.ethernet.bind("devices", check_visible)
|
||||
icon.visible = network.wifi.bind("is_connected", check_visible)
|
||||
icon.visible = network.ethernet.bind("is_connected", check_visible)
|
||||
return icon
|
||||
|
||||
|
||||
def dnd_icon():
|
||||
return indicator_icon(
|
||||
image="notification-disabled-symbolic",
|
||||
visible=notifications.bind("dnd"),
|
||||
)
|
||||
|
||||
|
||||
def recorder_icon():
|
||||
def check_state(icon: Widget.Icon) -> None:
|
||||
if recorder.is_paused:
|
||||
icon.remove_css_class("active")
|
||||
else:
|
||||
icon.add_css_class("active")
|
||||
|
||||
icon = indicator_icon(
|
||||
image="media-record-symbolic",
|
||||
visible=recorder.bind("active"),
|
||||
)
|
||||
|
||||
icon.add_css_class("record-indicator")
|
||||
|
||||
recorder.connect("notify::is-paused", lambda x, y: check_state(icon))
|
||||
|
||||
return icon
|
||||
|
||||
|
||||
def volume_icon():
|
||||
return indicator_icon(
|
||||
image=audio.speaker.bind("icon_name"),
|
||||
)
|
||||
|
||||
|
||||
def status_icons():
|
||||
return Widget.Box(
|
||||
child=[recorder_icon(), wifi_icon(), ethernet_icon(), volume_icon(), dnd_icon()]
|
||||
)
|
||||
@@ -0,0 +1,21 @@
|
||||
from ignis.widgets import Widget
|
||||
from ignis.exceptions import HyprlandIPCNotFoundError
|
||||
from ignis.services.hyprland import HyprlandService
|
||||
|
||||
try:
|
||||
hyprland = HyprlandService.get_default()
|
||||
|
||||
def kb_layout():
|
||||
return Widget.Button(
|
||||
css_classes=["kb-layout", "unset"],
|
||||
on_click=lambda x: hyprland.switch_kb_layout(),
|
||||
child=Widget.Label(
|
||||
label=hyprland.bind(
|
||||
"kb_layout", transform=lambda value: value[:2].lower()
|
||||
)
|
||||
),
|
||||
)
|
||||
except HyprlandIPCNotFoundError:
|
||||
|
||||
def kb_layout():
|
||||
return
|
||||
@@ -0,0 +1,51 @@
|
||||
from ignis.widgets import Widget
|
||||
from ignis.app import IgnisApp
|
||||
from ignis.services.applications import ApplicationsService
|
||||
|
||||
applications = ApplicationsService.get_default()
|
||||
app = IgnisApp.get_default()
|
||||
|
||||
|
||||
class AppItem(Widget.Button):
|
||||
def __init__(self, app):
|
||||
menu = Widget.PopoverMenu(
|
||||
items=[
|
||||
Widget.MenuItem(label="Launch", on_activate=lambda x: app.launch()),
|
||||
Widget.Separator(),
|
||||
]
|
||||
+ [
|
||||
Widget.MenuItem(
|
||||
label=i.name, on_activate=lambda x, action=i: action.launch()
|
||||
)
|
||||
for i in app.actions
|
||||
]
|
||||
+ [
|
||||
Widget.Separator(),
|
||||
Widget.MenuItem(label="Unpin", on_activate=lambda x: app.unpin()),
|
||||
]
|
||||
)
|
||||
|
||||
super().__init__(
|
||||
child=Widget.Box(child=[Widget.Icon(image=app.icon, pixel_size=32), menu]),
|
||||
on_click=lambda x: app.launch(),
|
||||
on_right_click=lambda x: menu.popup(),
|
||||
css_classes=["pinned-app", "unset"],
|
||||
)
|
||||
|
||||
|
||||
def launcher_button():
|
||||
return Widget.Button(
|
||||
child=Widget.Icon(image="start-here-symbolic", pixel_size=32),
|
||||
on_click=lambda x: app.toggle_window("ignis_LAUNCHER"),
|
||||
css_classes=["pinned-app", "unset"],
|
||||
)
|
||||
|
||||
|
||||
def pinned_apps():
|
||||
return Widget.Box(
|
||||
child=applications.bind(
|
||||
"pinned",
|
||||
transform=lambda value: [AppItem(app) for app in value]
|
||||
+ [launcher_button()],
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,37 @@
|
||||
from ignis.widgets import Widget
|
||||
from ignis.services.system_tray import SystemTrayService
|
||||
|
||||
system_tray = SystemTrayService.get_default()
|
||||
|
||||
|
||||
class TrayItem(Widget.Button):
|
||||
def __init__(self, item):
|
||||
if item.menu:
|
||||
menu = item.menu.copy()
|
||||
else:
|
||||
menu = None
|
||||
|
||||
super().__init__(
|
||||
child=Widget.Box(
|
||||
child=[
|
||||
Widget.Icon(image=item.bind("icon"), pixel_size=24),
|
||||
menu,
|
||||
]
|
||||
),
|
||||
tooltip_text=item.bind("tooltip"),
|
||||
on_click=lambda x: item.activate(),
|
||||
on_right_click=lambda x: menu.popup() if menu else None,
|
||||
css_classes=["tray-item", "unset"],
|
||||
)
|
||||
|
||||
item.connect("removed", lambda x: self.unparent())
|
||||
|
||||
|
||||
def tray():
|
||||
return Widget.Box(
|
||||
css_classes=["tray"],
|
||||
setup=lambda self: system_tray.connect(
|
||||
"added", lambda x, item: self.append(TrayItem(item))
|
||||
),
|
||||
spacing=10,
|
||||
)
|
||||
@@ -0,0 +1,25 @@
|
||||
from ignis.widgets import Widget
|
||||
from ignis.exceptions import HyprlandIPCNotFoundError
|
||||
from ignis.services.hyprland import HyprlandService
|
||||
import os
|
||||
|
||||
def toggle_engine():
|
||||
os.system("cd /home/timo/.config/hypr/linux-wallpaperengine && ./linux-wallpaperengine 2657260174 --screen-root DP-3")
|
||||
|
||||
try:
|
||||
hyprland = HyprlandService.get_default()
|
||||
|
||||
def wallpaper_engine_widget():
|
||||
return Widget.Button(
|
||||
css_classes=["kb-layout", "unset"],
|
||||
on_click=lambda x: os.system("cd /home/timo/.config/hypr/linux-wallpaperengine && ./linux-wallpaperengine 2657260174 --screen-root DP-3"),
|
||||
child=Widget.Label(
|
||||
label=hyprland.bind(
|
||||
"kb_layout", transform=lambda value: value[:2].lower()
|
||||
)
|
||||
),
|
||||
)
|
||||
except HyprlandIPCNotFoundError:
|
||||
|
||||
def kb_layout():
|
||||
return
|
||||
@@ -0,0 +1,46 @@
|
||||
from ignis.widgets import Widget
|
||||
from ignis.exceptions import HyprlandIPCNotFoundError
|
||||
from ignis.services.hyprland import HyprlandService
|
||||
|
||||
|
||||
class WorkspaceButton(Widget.Button):
|
||||
def __init__(self, workspace: dict) -> None:
|
||||
super().__init__(
|
||||
css_classes=["workspace", "unset"],
|
||||
on_click=lambda x, id=workspace["id"]: hyprland.switch_to_workspace(id),
|
||||
halign="start",
|
||||
valign="center",
|
||||
)
|
||||
if workspace["id"] == hyprland.active_workspace["id"]:
|
||||
self.add_css_class("active")
|
||||
|
||||
|
||||
try:
|
||||
hyprland = HyprlandService.get_default()
|
||||
|
||||
def scroll_workspaces(direction: str) -> None:
|
||||
current = hyprland.active_workspace["id"]
|
||||
if direction == "up":
|
||||
target = current - 1
|
||||
hyprland.switch_to_workspace(target)
|
||||
else:
|
||||
target = current + 1
|
||||
if target == 11:
|
||||
return
|
||||
hyprland.switch_to_workspace(target)
|
||||
|
||||
def workspaces():
|
||||
return Widget.EventBox(
|
||||
on_scroll_up=lambda x: scroll_workspaces("up"),
|
||||
on_scroll_down=lambda x: scroll_workspaces("down"),
|
||||
css_classes=["workspaces"],
|
||||
child=hyprland.bind(
|
||||
"workspaces",
|
||||
transform=lambda value: [WorkspaceButton(i) for i in value],
|
||||
),
|
||||
)
|
||||
|
||||
except HyprlandIPCNotFoundError:
|
||||
|
||||
def workspaces():
|
||||
return
|
||||
Reference in New Issue
Block a user