💥 eww(bar/workspaces): fix workspace indicator with a literal script
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env
|
||||
|
||||
hyprctl -j activeworkspace | jq -c
|
||||
|
||||
handle() {
|
||||
case $1 in
|
||||
workspace*) hyprctl -j activeworkspace | jq -c ;;
|
||||
esac
|
||||
}
|
||||
|
||||
socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | while read -r line; do handle "$line"; done
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
send_notification() {
|
||||
notify-send -u normal -a "Color Picker" "$1" "$2"
|
||||
}
|
||||
|
||||
# Check if user has hyprpicker installed
|
||||
if ! [[ -f /bin/hyprpicker ]]; then
|
||||
send_notification "An error occurred" "Looks like you don't have Hyprpicker installed! Try installing it before using the Color Picker tool."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
selected_color=$(hyprpicker)
|
||||
|
||||
if ! [[ $selected_color == "" ]]; then
|
||||
wl-copy $selected_color
|
||||
send_notification "Selected Color" "The selected color is <span foreground='$selected_color'>$selected_color</span>, it was also copied to your clipboard!"
|
||||
fi
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Original Script by vimjoyer, modified by retrozinndev
|
||||
# Licensed under the MIT License, as in vimjoyer's repository and also in retrozinndev's Hyprland Dots.
|
||||
# This script watches for notifications to display as a popup in eww.
|
||||
|
||||
import threading
|
||||
import time
|
||||
import dbus
|
||||
import dbus.service
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
from gi.repository import GLib
|
||||
|
||||
class Notification:
|
||||
def __init__(self, app_name, summary, body, icon, replaces_id, timeout):
|
||||
self.app_name = app_name
|
||||
self.summary = summary
|
||||
self.body = body
|
||||
self.icon = icon
|
||||
self.replaces_id = replaces_id
|
||||
|
||||
notifications_on_popup = []
|
||||
notifications = []
|
||||
notification_timeout = 10 # In seconds
|
||||
|
||||
def remove_popup_notification(notification):
|
||||
time.sleep(notification_timeout)
|
||||
notifications.remove(notification)
|
||||
reload_output()
|
||||
|
||||
def add_popup_notification(notification):
|
||||
notifications.insert(0, notification)
|
||||
reload_output()
|
||||
timer_thread = threading.Thread(target=remove_popup_notification, args=(notification,)) # Only used for notification popup, not history
|
||||
timer_thread.start()
|
||||
|
||||
def reload_output():
|
||||
lastItem_notifications = len(notifications) - 1
|
||||
output = ""
|
||||
|
||||
for item in notifications:
|
||||
if item is not notifications[lastItem_notifications]:
|
||||
output = output + f"{{ \"applicationName\": \"{item.app_name}\", \"image\": \"{item.icon}\", \"summary\": \"{item.summary}\", \"body\": \"{item.body}\", \"id\": {item.replaces_id}, \"timeout\": {item.timeout} }}, "
|
||||
|
||||
else:
|
||||
output = "["+ output + f"{{ \"applicationName\": \"{item.app_name}\", \"image\": \"{item.icon}\", \"summary\": \"{item.summary}\", \"body\": \"{item.body}\", \"id\": {item.replaces_id}, \"timeout\": {item.timeout} }} ]"
|
||||
|
||||
print(f"{output}", flush=True)
|
||||
|
||||
|
||||
class NotificationServer(dbus.service.Object):
|
||||
def __init__(self):
|
||||
bus_name = dbus.service.BusName("org.freedesktop.Notifications", bus=dbus.SessionBus())
|
||||
dbus.service.Object.__init__(self, bus_name, "/org/freedesktop/Notifications")
|
||||
|
||||
@dbus.service.method("org.freedesktop.Notifications", in_signature="susssasa{ss}i", out_signature="u")
|
||||
def Notify(self, app_name, replaces_id, icon, summary, body, actions, hints, timeout):
|
||||
add_popup_notification(Notification(app_name, summary, body, icon, replaces_id, timeout))
|
||||
return 0
|
||||
|
||||
@dbus.service.method("org.freedesktop.Notifications", out_signature="ssss")
|
||||
def GetServerInformation(self):
|
||||
return ("Custom Notification Server", "ExampleNS", "1.0", "1.2")
|
||||
|
||||
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
server = NotificationServer()
|
||||
mainloop = GLib.MainLoop()
|
||||
mainloop.run()
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
prev_history=$(dunstctl history)
|
||||
|
||||
while true; do
|
||||
if ! [[ $prev_history == $(dunstctl history) ]]; then
|
||||
prev_history=$(dunstctl history)
|
||||
echo "$(echo $prev_history | jq -c '.data.[]')"
|
||||
fi
|
||||
done
|
||||
@@ -1,61 +0,0 @@
|
||||
# Original Script by vimjoyer, modified by retrozinndev
|
||||
# Licensed under the MIT License, as in vimjoyer's repository and also in retrozinndev's Hyprland Dots.
|
||||
|
||||
import dbus
|
||||
import dbus.service
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
from gi.repository import GLib
|
||||
import threading
|
||||
import time
|
||||
|
||||
class Notification:
|
||||
def __init__(self, app_name, summary, body, icon):
|
||||
self.app_name = app_name
|
||||
self.summary = summary
|
||||
self.body = body
|
||||
self.icon = icon
|
||||
|
||||
notifications = []
|
||||
|
||||
def remove_notification(notification):
|
||||
time.sleep(10)
|
||||
notifications.remove(notification)
|
||||
reload_output()
|
||||
|
||||
def add_notification(notification):
|
||||
notifications.insert(0, notification)
|
||||
reload_output()
|
||||
timer_thread = threading.Thread(target=remove_notification, args=(notification,))
|
||||
timer_thread.start()
|
||||
|
||||
def reload_output():
|
||||
|
||||
output = ""
|
||||
for notification in notifications:
|
||||
output = "aaaaaaaa"
|
||||
|
||||
output.replace('\n', ' ')
|
||||
print(f"{ output }", flush=True)
|
||||
|
||||
|
||||
class NotificationServer(dbus.service.Object):
|
||||
def __init__(self):
|
||||
bus_name = dbus.service.BusName("org.freedesktop.Notifications", bus=dbus.SessionBus())
|
||||
dbus.service.Object.__init__(self, bus_name, "/org/freedesktop/Notifications")
|
||||
|
||||
@dbus.service.method("org.freedesktop.Notifications", in_signature="susssasa{ss}i", out_signature="u")
|
||||
def Notify(self, app_name, replaces_id, app_icon, summary, body, actions, hints, timeout):
|
||||
add_notification(Notification(app_name, summary, body, app_icon))
|
||||
return 0
|
||||
|
||||
@dbus.service.method("org.freedesktop.Notifications", out_signature="ssss")
|
||||
def GetServerInformation(self):
|
||||
return ("Custom Notification Server", "ExampleNS", "1.0", "1.2")
|
||||
|
||||
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
server = NotificationServer()
|
||||
mainloop = GLib.MainLoop()
|
||||
mainloop.run()
|
||||
@@ -1,11 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# display workspaces before checking for events
|
||||
hyprctl -j workspaces | jq -c
|
||||
#!/usr/bin/env bash
|
||||
|
||||
print_workspaces_literal() {
|
||||
active_workspace_id=$(hyprctl -j activeworkspace | jq .id | xargs)
|
||||
existing_workspaces=$(hyprctl -j workspaces | jq .[].id | xargs)
|
||||
|
||||
output="
|
||||
(box :class \"workspaces\"
|
||||
:space-evenly false
|
||||
:orientation \"horizontal\""
|
||||
|
||||
for i in {1..10}; do
|
||||
output=$output"
|
||||
(button :onclick \"hyprctl dispatch workspace $i\"
|
||||
:class { $active_workspace_id == $i ? \"active\" : \"\" }
|
||||
:visible { \"$existing_workspaces\" =~ $i ? true : false }
|
||||
\"\")"
|
||||
|
||||
if [ $i == 10 ]; then
|
||||
output=$output")" # closes box if last
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$(echo $output | xargs -0)"
|
||||
}
|
||||
|
||||
# display workspaces on startup
|
||||
print_workspaces_literal
|
||||
|
||||
handle() {
|
||||
case $1 in
|
||||
workspace* | destroyworkspace*) hyprctl -j workspaces | jq -c ;;
|
||||
workspace*) print_workspaces_literal;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user