Upgrade to Agsv2 + Astal (#533)

* migrate to astal

* Reorganize project structure.

* progress

* Migrate Dashboard and Window Title modules.

* Migrate clock and notification bar modules.

* Remove unused code

* Media menu

* Rework network and volume modules

* Finish custom modules.

* Migrate battery bar module.

* Update battery module and organize helpers.

* Migrate workspace module.

* Wrap up bar modules.

* Checkpoint before I inevitbly blow something up.

* Updates

* Fix event propagation logic.

* Type fixes

* More type fixes

* Fix padding for event boxes.

* Migrate volume menu and refactor scroll event handlers.

* network module WIP

* Migrate network service.

* Migrate bluetooth menu

* Updates

* Migrate notifications

* Update scrolling behavior for custom modules.

* Improve popup notifications and add timer functionality.

* Migration notifications menu header/controls.

* Migrate notifications menu and consolidate notifications menu code.

* Migrate power menu.

* Dashboard progress

* Migrate dashboard

* Migrate media menu.

* Reduce media menu nesting.

* Finish updating media menu bindings to navigate active player.

* Migrate battery menu

* Consolidate code

* Migrate calendar menu

* Fix workspace logic to update on client add/change/remove and consolidate code.

* Migrate osd

* Consolidate hyprland service connections.

* Implement startup dropdown menu position allocation.

* Migrate settings menu (WIP)

* Settings dialo menu fixes

* Finish Dashboard menu

* Type updates

* update submoldule for types

* update github ci

* ci

* Submodule update

* Ci updates

* Remove type checking for now.

* ci fix

* Fix a bunch of stuff, losing track... need rest. Brb coffee

* Validate dropdown menu before render.

* Consolidate code and add auto-hide functionality.

* Improve auto-hide behavior.

* Consolidate audio menu code

* Organize bluetooth code

* Improve active player logic

* Properly dismiss a notification on action button resolution.

* Implement CLI command engine and migrate CLI commands.

* Handle variable disposal

* Bar component fixes and add hyprland startup rules.

* Handle potentially null bindings network and bluetooth bindings.

* Handle potentially null wired adapter.

* Fix GPU stats

* Handle poller for GPU

* Fix gpu bar logic.

* Clean up logic for stat bars.

* Handle wifi and wired bar icon bindings.

* Fix battery percentages

* Fix switch behavior

* Wifi staging fixes

* Reduce redundant hyprland service calls.

* Code cleanup

* Document the option code and reduce redundant calls to optimize performance.

* Remove outdated comment.

* Add JSDocs

* Add meson to build hyprpanel

* Consistency updates

* Organize commands

* Fix images not showing up on notifications.

* Remove todo

* Move hyprpanel configuration to the ~/.config/hyprpanel directory and add utility commands.

* Handle SRC directory for the bundled/built hyprpanel.

* Add namespaces to all windows

* Migrate systray

* systray updates

* Update meson to include ts, tsx and scss files.

* Remove log from meson

* Fix file choose path and make it float.

* Added a command to check the dependency status

* Update dep names.

* Get scale directly from env

* Add todo
This commit is contained in:
Jas Singh
2024-12-20 18:10:10 -08:00
committed by GitHub
parent 955eed6c60
commit 2ffd602910
605 changed files with 19543 additions and 15999 deletions

173
scripts/bluetooth.py Executable file
View File

@@ -0,0 +1,173 @@
#!/usr/bin/env python3
import dbus
import dbus.service
import dbus.mainloop.glib
from gi.repository import GLib
import subprocess
import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
AGENT_PATH = "/test/agent"
CAPABILITY = "NoInputNoOutput"
def send_notification_with_actions(title, message, actions, action_handler):
bus = dbus.SessionBus()
notification_object = bus.get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
notify_interface = dbus.Interface(notification_object, "org.freedesktop.Notifications")
bus.add_signal_receiver(action_handler,
dbus_interface="org.freedesktop.Notifications",
signal_name="ActionInvoked")
notify_interface.Notify("bluetooth_agent", 0, "", title, message, actions, {}, -1)
class Agent(dbus.service.Object):
def __init__(self, bus):
dbus.service.Object.__init__(self, bus, AGENT_PATH)
@dbus.service.method("org.bluez.Agent1", in_signature="", out_signature="")
def Release(self):
logging.info("Release")
def get_device_name(self, device):
bus = dbus.SystemBus()
device_proxy = bus.get_object("org.bluez", device)
device_properties = dbus.Interface(device_proxy, "org.freedesktop.DBus.Properties")
return device_properties.Get("org.bluez.Device1", "Name")
@dbus.service.method("org.bluez.Agent1", in_signature="o", out_signature="")
def RequestPinCode(self, device):
device_name = self.get_device_name(device)
logging.info(f"RequestPinCode {device_name} ({device})")
self.request_input("Enter PIN code", f"Enter PIN code for device {device_name}", device, "pin")
@dbus.service.method("org.bluez.Agent1", in_signature="o", out_signature="u")
def RequestPasskey(self, device):
device_name = self.get_device_name(device)
logging.info(f"RequestPasskey {device_name} ({device})")
self.request_input("Enter Passkey", f"Enter passkey for device {device_name}", device, "passkey")
@dbus.service.method("org.bluez.Agent1", in_signature="ou", out_signature="")
def DisplayPasskey(self, device, passkey):
device_name = self.get_device_name(device)
logging.info(f"DisplayPasskey {device_name} passkey {passkey}")
send_notification_with_actions("Bluetooth Pairing Request", f"Passkey for device {device_name} is {passkey}", [], lambda *args: None)
@dbus.service.method("org.bluez.Agent1", in_signature="ou", out_signature="")
def RequestConfirmation(self, device, passkey):
device_name = self.get_device_name(device)
logging.info(f"RequestConfirmation {device_name} passkey {passkey}")
actions = ["confirm", "Confirm", "deny", "Deny"]
def action_handler(notification_id, action_key):
if action_key == "confirm":
logging.info(f"Confirmed pairing for {device_name}")
self.send_reply(device)
elif action_key == "deny":
logging.info(f"Denied pairing for {device_name}")
self.send_error(device, "org.bluez.Error.Rejected")
send_notification_with_actions("Bluetooth Pairing Request",
f"Confirm passkey {passkey} for device {device_name}",
actions, action_handler)
return
@dbus.service.method("org.bluez.Agent1", in_signature="o", out_signature="")
def RequestAuthorization(self, device):
device_name = self.get_device_name(device)
logging.info(f"RequestAuthorization {device_name}")
actions = ["confirm", "Confirm", "deny", "Deny"]
def action_handler(notification_id, action_key):
if action_key == "confirm":
logging.info(f"Authorized device {device_name}")
self.send_reply(device)
elif action_key == "deny":
logging.info(f"Denied authorization for {device_name}")
self.send_error(device, "org.bluez.Error.Rejected")
send_notification_with_actions("Bluetooth Service Authorization",
f"Authorize device {device_name}",
actions, action_handler)
return
@dbus.service.method("org.bluez.Agent1", in_signature="os", out_signature="")
def AuthorizeService(self, device, uuid):
device_name = self.get_device_name(device)
logging.info(f"AuthorizeService {device_name} uuid {uuid}")
actions = ["confirm", "Confirm", "deny", "Deny"]
def action_handler(notification_id, action_key):
if action_key == "confirm":
logging.info(f"Authorized service {uuid} for device {device_name}")
self.send_reply(device)
elif action_key == "deny":
logging.info(f"Denied authorization for service {uuid} on device {device_name}")
self.send_error(device, "org.bluez.Error.Rejected")
send_notification_with_actions("Bluetooth Service Authorization",
f"Authorize service {uuid} for device {device_name}",
actions, action_handler)
return
@dbus.service.method("org.bluez.Agent1", in_signature="", out_signature="")
def Cancel(self):
logging.info("Cancel")
def request_input(self, title, message, device, input_type):
def action_handler(notification_id, action_key):
if action_key == "input":
result = subprocess.run(["zenity", "--entry", "--title", title, "--text", message], capture_output=True, text=True)
user_input = result.stdout.strip()
if input_type == "pin":
self.handle_pin_input(device, user_input)
elif input_type == "passkey":
self.handle_passkey_input(device, user_input)
elif action_key == "cancel":
self.send_error(device, "org.bluez.Error.Rejected")
actions = ["input", "Enter", "cancel", "Cancel"]
send_notification_with_actions(title, message, actions, action_handler)
def handle_pin_input(self, device, pin_code):
logging.info(f"PIN code entered for {device}: {pin_code}")
self.send_reply(device)
def handle_passkey_input(self, device, passkey):
logging.info(f"Passkey entered for {device}: {passkey}")
self.send_reply(device)
def send_reply(self, device):
logging.info(f"Sending reply for {device}")
bus = dbus.SystemBus()
agent = bus.get_object("org.bluez", device)
agent_interface = dbus.Interface(agent, "org.bluez.Device1")
agent_interface.Pair(reply_handler=self.success_callback, error_handler=self.error_callback)
def send_error(self, device, error):
logging.info(f"Sending error for {device}")
bus = dbus.SystemBus()
agent = bus.get_object("org.bluez", device)
agent_interface = dbus.Interface(agent, "org.bluez.Device1")
agent_interface.CancelPairing(reply_handler=self.success_callback, error_handler=self.error_callback)
def success_callback(self):
logging.info("Operation succeeded")
def error_callback(self, error):
logging.error(f"Operation failed: {error}")
def register_agent():
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"), "org.bluez.AgentManager1")
path = AGENT_PATH
agent = Agent(bus)
manager.RegisterAgent(path, CAPABILITY)
manager.RequestDefaultAgent(path)
logging.info("Agent registered")
if __name__ == "__main__":
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
register_agent()
loop = GLib.MainLoop()
loop.run()

View File

@@ -0,0 +1,9 @@
#!/bin/sh
export HYPRPANEL_DATADIR="@DATADIR@"
if [ "$#" -eq 0 ]; then
exec gjs -m "@DATADIR@/hyprpanel.js"
else
exec astal -i hyprpanel "$@"
fi

28
scripts/install_fonts.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
SOURCE_DIR="./assets/fonts"
DEST_DIR="$HOME/.local/share/fonts"
DEST_PATH="$DEST_DIR/NFP"
if [ ! -d "$SOURCE_DIR" ]; then
echo "Source directory '$SOURCE_DIR' does not exist."
exit 1
fi
if [ ! -d "$DEST_PATH" ]; then
echo "Destination directory '$DEST_PATH' does not exist. Creating it..."
mkdir -p "$DEST_PATH"
fi
if [ -z "$(ls -A "$SOURCE_DIR")" ]; then
echo "Source directory '$SOURCE_DIR' is empty. No files to copy."
exit 1
fi
echo "Copying fonts from '$SOURCE_DIR' to '$DEST_PATH'..."
cp -r "$SOURCE_DIR"/* "$DEST_PATH"
echo "Updating font cache..."
fc-cache -fv
echo "Fonts installed successfully."

80
scripts/screen_record.sh Executable file
View File

@@ -0,0 +1,80 @@
#!/usr/bin/env bash
outputDir="$HOME/Videos/Screencasts"
checkRecording() {
if pgrep -f "gpu-screen-recorder" >/dev/null; then
return 0
else
return 1
fi
}
startRecording() {
if checkRecording; then
echo "A recording is already in progress."
exit 1
fi
target="$2"
outputFile="recording_$(date +%Y-%m-%d_%H-%M-%S).mp4"
outputPath="$outputDir/$outputFile"
mkdir -p "$outputDir"
if [ -z "$target" ]; then
echo "Usage: $0 start screen [screen_name]"
exit 1
fi
GPU_TYPE=$(lspci | grep -E 'VGA|3D' | grep -Ev '00:02.0|Integrated' >/dev/null && echo "" || echo "-encoder cpu")
gpu-screen-recorder \
-w "$target" \
-f 60 \
-k h264 \
-a "$(pactl get-default-sink).monitor" \
-o "$outputPath" \
$GPU_TYPE &
echo "Recording started. Output will be saved to $outputPath"
}
stopRecording() {
if ! checkRecording; then
echo "No recording is in progress."
exit 1
fi
pkill -SIGINT -f gpu-screen-recorder
recentFile=$(ls -t "$outputDir"/recording_*.mp4 | head -n 1)
notify-send "Recording stopped" "Your recording has been saved." \
-i video-x-generic \
-a "Screen Recorder" \
-t 10000 \
-u normal \
--action="scriptAction:-xdg-open $outputDir=Directory" \
--action="scriptAction:-xdg-open $recentFile=Play"
}
case "$1" in
start)
startRecording "$@"
;;
stop)
stopRecording
;;
status)
if checkRecording; then
echo "recording"
else
echo "not recording"
fi
;;
*)
echo "Usage: $0 {start [screen_name|window_id]|stop|status}"
exit 1
;;
esac

36
scripts/snapshot.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
outputDir="$HOME/Pictures/Screenshots/"
outputFile="snapshot_$(date +%Y-%m-%d_%H-%M-%S).png"
outputPath="$outputDir/$outputFile"
mkdir -p "$outputDir"
mode=${1:-area}
case "$mode" in
active)
command="grimblast copysave active $outputPath"
;;
output)
command="grimblast copysave output $outputPath"
;;
area)
command="grimblast copysave area $outputPath"
;;
*)
echo "Invalid option: $mode"
echo "Usage: $0 {active|output|area}"
exit 1
;;
esac
if eval "$command"; then
recentFile=$(find "$outputDir" -name 'snapshot_*.png' -printf '%T+ %p\n' | sort -r | head -n 1 | cut -d' ' -f2-)
notify-send "Grimblast" "Your snapshot has been saved." \
-i video-x-generic \
-a "Grimblast" \
-t 7000 \
-u normal \
--action="scriptAction:-xdg-open $outputDir=Directory" \
--action="scriptAction:-xdg-open $recentFile=View"
fi