From cdfab0a5b56ea29f197f906b998baf8e174ee57d Mon Sep 17 00:00:00 2001 From: mmmfchal-create Date: Sun, 1 Feb 2026 15:34:13 +0100 Subject: [PATCH 1/2] Add files via upload --- widgets/setup-screen-share.sh | 80 +++++++++++++++++++++++++++++++++++ widgets/themes.json | 49 +++++++++++++++++++++ widgets/widget.py | 77 +++++++++++++++++++++++++++++++++ 3 files changed, 206 insertions(+) create mode 100644 widgets/setup-screen-share.sh create mode 100644 widgets/themes.json create mode 100644 widgets/widget.py diff --git a/widgets/setup-screen-share.sh b/widgets/setup-screen-share.sh new file mode 100644 index 0000000..e0b6031 --- /dev/null +++ b/widgets/setup-screen-share.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# Hyprland Screen Sharing Setup Script +# This script installs and configures screen sharing for Hyprland + +set -e + +echo "=== Hyprland Screen Sharing Setup ===" +echo "" + +# Check if running on Arch-based system +if ! command -v pacman &> /dev/null; then + echo "Error: This script is designed for Arch Linux based distributions" + exit 1 +fi + +# Check if running as root (should NOT be) +if [ "$EUID" -eq 0 ]; then + echo "Error: Please do not run this script as root" + exit 1 +fi + +echo "Step 1: Installing required packages..." +sudo pacman -S --needed --noconfirm xdg-desktop-portal-hyprland pipewire wireplumber xdg-desktop-portal 2>/dev/null || { + echo "Some packages may already be installed" +} + +echo "" +echo "Step 2: Enabling services..." +# Enable and start user services +systemctl --user enable pipewire.service +systemctl --user enable wireplumber.service +systemctl --user enable pipewire.socket +systemctl --user start pipewire.socket +systemctl --user start pipewire.service +systemctl --user start wireplumber.service + +echo "" +echo "Step 3: Creating portal configuration..." + +# Create portal configuration directory +mkdir -p ~/.config/xdg-desktop-portal + +# Create Hyprland portal config +cat > ~/.config/xdg-desktop-portal/hyprland-portals.conf << 'EOF' +[preferred] +default=hyprland +org.freedesktop.impl.portal.Screenshot=hyprland +org.freedesktop.impl.portal.ScreenCast=hyprland +org.freedesktop.impl.portal.RemoteDesktop=hyprland +EOF + +echo "" +echo "Step 4: Checking environment variables..." + +# Check if XDG_CURRENT_DESKTOP is set correctly +if [ -z "$XDG_CURRENT_DESKTOP" ]; then + echo "WARNING: XDG_CURRENT_DESKTOP is not set!" + echo "Add this to your Hyprland config or ~/.bashrc/.zshrc:" + echo " export XDG_CURRENT_DESKTOP=Hyprland" +fi + +# Check if XDG_SESSION_TYPE is set correctly +if [ "$XDG_SESSION_TYPE" != "wayland" ]; then + echo "WARNING: XDG_SESSION_TYPE is not set to 'wayland'!" + echo "Add this to your Hyprland config or ~/.bashrc/.zshrc:" + echo " export XDG_SESSION_TYPE=wayland" +fi + +echo "" +echo "=== Setup Complete ===" +echo "" +echo "To verify screen sharing works:" +echo "1. Restart your Hyprland session (log out and log back in)" +echo "2. Open a browser and go to: https://mozilla.github.io/webrtc-landing/gum_test.html" +echo "3. Try sharing your screen" +echo "" +echo "Troubleshooting:" +echo "- If Chrome/Discord can't share Wayland windows, use --enable-features=WaylandWindowDecorations --ozone-platform-hint=auto" +echo "- Check 'systemctl --user status xdg-desktop-portal-hyprland' if issues occur" +echo "- Ensure your monitor bit depth matches in Hyprland config" diff --git a/widgets/themes.json b/widgets/themes.json new file mode 100644 index 0000000..d8cb52c --- /dev/null +++ b/widgets/themes.json @@ -0,0 +1,49 @@ +{ + "themes": { + "gruvbox": { + "background": "#282828", + "foreground": "#fbf1c7", + "primary": "#85A598", + "secondary": "#A89A85", + "accent": "#fabd2f", + "surface": "#3c3836", + "panel": "#504945" + }, + "dracula": { + "background": "#282a36", + "foreground": "#f8f8f2", + "primary": "#bd93f9", + "secondary": "#6272a4", + "accent": "#ff79c6", + "surface": "#44475a", + "panel": "#6272a4" + }, + "nord": { + "background": "#2e3440", + "foreground": "#d8dee9", + "primary": "#88c0d0", + "secondary": "#5e81ac", + "accent": "#81a1c1", + "surface": "#3b4252", + "panel": "#434c5e" + }, + "solarized-dark": { + "background": "#002b36", + "foreground": "#839496", + "primary": "#268bd2", + "secondary": "#586e75", + "accent": "#b58900", + "surface": "#073642", + "panel": "#586e75" + }, + "monokai": { + "background": "#272822", + "foreground": "#f8f8f2", + "primary": "#66d9ef", + "secondary": "#75715e", + "accent": "#fd971f", + "surface": "#383830", + "panel": "#49483e" + } + } +} \ No newline at end of file diff --git a/widgets/widget.py b/widgets/widget.py new file mode 100644 index 0000000..f42a83e --- /dev/null +++ b/widgets/widget.py @@ -0,0 +1,77 @@ +""" +An App to show the current time with theme support. +""" + +import json +import sys +from datetime import datetime +from pathlib import Path + +from textual.app import App, ComposeResult +from textual.widgets import Digits + + +def load_themes(): + """Load themes from themes.json file.""" + themes_file = Path(__file__).parent / "themes.json" + with open(themes_file) as f: + data = json.load(f) + return data["themes"] + + +def get_theme_css(theme_name: str) -> str: + """Generate CSS for a specific theme.""" + themes = load_themes() + if theme_name not in themes: + available = ", ".join(themes.keys()) + raise ValueError(f"Theme '{theme_name}' not found. Available: {available}") + + theme = themes[theme_name] + return f""" + Screen {{ + align: center middle; + background: {theme['background']}; + }} + Digits {{ + width: auto; + color: {theme['foreground']}; + }} + """ + + +class ClockApp(App): + CSS = """ + Screen { align: center middle; background: #282828; } + Digits { width: auto; color: #fbf1c7; } + """ + + def __init__(self, theme_name: str = "gruvbox", **kwargs): + self.theme_name = theme_name + # Override CSS with theme + ClockApp.CSS = get_theme_css(theme_name) + super().__init__(**kwargs) + + def compose(self) -> ComposeResult: + yield Digits("") + + def on_ready(self) -> None: + self.update_clock() + self.set_interval(1, self.update_clock) + + def update_clock(self) -> None: + clock = datetime.now().time() + self.query_one(Digits).update(f"{clock:%T}") + + +if __name__ == "__main__": + # Parse command line arguments for theme selection + theme = "gruvbox" + if len(sys.argv) > 1: + theme = sys.argv[1] + + try: + app = ClockApp(theme_name=theme) + app.run() + except ValueError as e: + print(f"Error: {e}") + sys.exit(1) From c7a5844c40635bf8741567867ef4235babebaa24 Mon Sep 17 00:00:00 2001 From: mmmfchal-create Date: Sun, 1 Feb 2026 15:36:35 +0100 Subject: [PATCH 2/2] Delete widgets/setup-screen-share.sh --- widgets/setup-screen-share.sh | 80 ----------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 widgets/setup-screen-share.sh diff --git a/widgets/setup-screen-share.sh b/widgets/setup-screen-share.sh deleted file mode 100644 index e0b6031..0000000 --- a/widgets/setup-screen-share.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# Hyprland Screen Sharing Setup Script -# This script installs and configures screen sharing for Hyprland - -set -e - -echo "=== Hyprland Screen Sharing Setup ===" -echo "" - -# Check if running on Arch-based system -if ! command -v pacman &> /dev/null; then - echo "Error: This script is designed for Arch Linux based distributions" - exit 1 -fi - -# Check if running as root (should NOT be) -if [ "$EUID" -eq 0 ]; then - echo "Error: Please do not run this script as root" - exit 1 -fi - -echo "Step 1: Installing required packages..." -sudo pacman -S --needed --noconfirm xdg-desktop-portal-hyprland pipewire wireplumber xdg-desktop-portal 2>/dev/null || { - echo "Some packages may already be installed" -} - -echo "" -echo "Step 2: Enabling services..." -# Enable and start user services -systemctl --user enable pipewire.service -systemctl --user enable wireplumber.service -systemctl --user enable pipewire.socket -systemctl --user start pipewire.socket -systemctl --user start pipewire.service -systemctl --user start wireplumber.service - -echo "" -echo "Step 3: Creating portal configuration..." - -# Create portal configuration directory -mkdir -p ~/.config/xdg-desktop-portal - -# Create Hyprland portal config -cat > ~/.config/xdg-desktop-portal/hyprland-portals.conf << 'EOF' -[preferred] -default=hyprland -org.freedesktop.impl.portal.Screenshot=hyprland -org.freedesktop.impl.portal.ScreenCast=hyprland -org.freedesktop.impl.portal.RemoteDesktop=hyprland -EOF - -echo "" -echo "Step 4: Checking environment variables..." - -# Check if XDG_CURRENT_DESKTOP is set correctly -if [ -z "$XDG_CURRENT_DESKTOP" ]; then - echo "WARNING: XDG_CURRENT_DESKTOP is not set!" - echo "Add this to your Hyprland config or ~/.bashrc/.zshrc:" - echo " export XDG_CURRENT_DESKTOP=Hyprland" -fi - -# Check if XDG_SESSION_TYPE is set correctly -if [ "$XDG_SESSION_TYPE" != "wayland" ]; then - echo "WARNING: XDG_SESSION_TYPE is not set to 'wayland'!" - echo "Add this to your Hyprland config or ~/.bashrc/.zshrc:" - echo " export XDG_SESSION_TYPE=wayland" -fi - -echo "" -echo "=== Setup Complete ===" -echo "" -echo "To verify screen sharing works:" -echo "1. Restart your Hyprland session (log out and log back in)" -echo "2. Open a browser and go to: https://mozilla.github.io/webrtc-landing/gum_test.html" -echo "3. Try sharing your screen" -echo "" -echo "Troubleshooting:" -echo "- If Chrome/Discord can't share Wayland windows, use --enable-features=WaylandWindowDecorations --ozone-platform-hint=auto" -echo "- Check 'systemctl --user status xdg-desktop-portal-hyprland' if issues occur" -echo "- Ensure your monitor bit depth matches in Hyprland config"