✨ a lot of changes and new stuff! started using mako
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# output current window before event trigger to prevent issues
|
||||
hyprctl -j activewindow | jq -c
|
||||
hyprctl -j activewindow | jq -c | sed 's/\\[n]//g'
|
||||
|
||||
handle() {
|
||||
case $1 in
|
||||
activewindow*) hyprctl -j activewindow | jq -c ;;
|
||||
activewindow*) hyprctl -j activewindow | jq -c | sed 's/\\[n]//g' ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# arg1,$1 should be one of the options listed in help command;
|
||||
# arg2,$2 should be the literal window name as defined in eww configuration.
|
||||
|
||||
check_if_empty() {
|
||||
if [[ -z $1 ]]; then
|
||||
echo "[error] argument $2 is empty!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
--help | -h | help | h)
|
||||
printf \
|
||||
"This is a helper script that helps opening/closing eww windows on
|
||||
retrozinndev's Hyprland Dots, by checking if the window is already
|
||||
open/closed before doing anything, also changes eww state variables.
|
||||
This needs a variable like window_state_WINDOWNAME to work, where
|
||||
WINDOWNAME is the literal name of the declared window inside the
|
||||
eww configuration you are using.
|
||||
|
||||
Usage:
|
||||
arg1 arg2
|
||||
./eww-window.sh [SINGLE OPTION] [WINDOW_NAME]
|
||||
|
||||
Options:
|
||||
-h, --help, help: Shows this help message;
|
||||
--open, open: Opens a window and changes its state variable to
|
||||
\"open\" if not open, or else does nothing;
|
||||
--toggle, toggle: Toggles a window. If open, the specified
|
||||
window is closed, if closed, the
|
||||
specified window is open. Same thing goes to
|
||||
the eww window state variable;
|
||||
--close, close: Closes a window and also changes its state
|
||||
variable to \"closed\" if open, or else does
|
||||
nothing.
|
||||
|
||||
|
||||
Developer: retrozinndev (João Dias), https://github.com/retrozinndev
|
||||
Issue tracker: https://github.com/retrozinndev/Hyprland-Dots/issues
|
||||
Licensed under the MIT License, as in retrozinndev's Hyprland-Dots repo."
|
||||
;;
|
||||
|
||||
--open | open)
|
||||
check_if_empty $2 "WINDOW_NAME"
|
||||
if [[ $(eww get "window_state_$2") == "closed" ]]; then
|
||||
eww open "$2"
|
||||
eww update "window_state_$2=open"
|
||||
else
|
||||
echo "[info] Window '$2' is already open, ignored."
|
||||
fi
|
||||
;;
|
||||
|
||||
--close | close)
|
||||
check_if_empty $2 "WINDOW_NAME"
|
||||
if [[ $(eww get "window_state_$2") == "open" ]]; then
|
||||
eww close "$2"
|
||||
eww update "window_state_$2=closed"
|
||||
else
|
||||
echo "[info] Window '$2' is already closed, ignored."
|
||||
fi
|
||||
;;
|
||||
|
||||
--toggle | toggle)
|
||||
check_if_empty $2 "WINDOW_NAME"
|
||||
if [[ $(eww get "window_state_$2") == "closed" ]]; then
|
||||
eww open "$2"
|
||||
eww update "window_state_$2=open"
|
||||
else
|
||||
eww close "$2"
|
||||
eww update "window_state_$2=closed"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "[error] Action not specified or incorrect command order. Good example: \`./eww-window.sh open bar\`"
|
||||
;;
|
||||
esac
|
||||
@@ -16,6 +16,7 @@ source_vol=$(get_vol $source_)
|
||||
|
||||
print_json
|
||||
|
||||
# Loop
|
||||
pactl subscribe | grep --line-buffered -e "on sink" -e "on source" | while read -r; do
|
||||
|
||||
output_vol=$(get_vol $sink_)
|
||||
|
||||
@@ -134,7 +134,8 @@ class PlayerManager:
|
||||
"title": player.get_title(),
|
||||
"artist": player.get_artist(),
|
||||
"player": player.props.player_name.lower(),
|
||||
"artUrl": player.print_metadata_prop("mpris:artUrl")
|
||||
"artUrl": player.print_metadata_prop("mpris:artUrl"),
|
||||
"length": player.print_metadata_prop("mpris:length")
|
||||
}
|
||||
|
||||
sys.stdout.write(json.dumps(output) + "\n")
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
is_connected() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# initial notification history
|
||||
json_initial_history=$(makoctl history | jq -c '.data[]' | sed 's/\\[n]/\\n/g')
|
||||
echo $json_initial_history
|
||||
|
||||
while true; do
|
||||
# watch history every 200ms
|
||||
sleep .2
|
||||
|
||||
# frequently updated history variable
|
||||
json_history=$(makoctl history | jq -c '.data[]' | sed 's/\\[n]/\\n/g')
|
||||
|
||||
if ! [[ "$json_initial_history" == "$json_history" ]]; then
|
||||
json_initial_history="$json_history"
|
||||
echo "$json_initial_history"
|
||||
fi
|
||||
done
|
||||
@@ -8,20 +8,22 @@ import threading
|
||||
import time
|
||||
import dbus
|
||||
import dbus.service
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
from gi.repository import GLib
|
||||
|
||||
class Notification:
|
||||
def __init__(self, app_name, summary, body, icon, replaces_id, timeout):
|
||||
def __init__(self, app_name, summary, body, icon, replaces_id):
|
||||
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
|
||||
notification_timeout = 8 # In seconds
|
||||
|
||||
def remove_popup_notification(notification):
|
||||
time.sleep(notification_timeout)
|
||||
@@ -31,19 +33,27 @@ def remove_popup_notification(notification):
|
||||
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 = threading.Thread(target=remove_popup_notification, args=(notification,))
|
||||
timer_thread.start()
|
||||
|
||||
def reload_output():
|
||||
lastItem_notifications = len(notifications) - 1
|
||||
output = ""
|
||||
|
||||
os.popen(". /etc/profile; eww open floating-notifications >> /dev/null")
|
||||
|
||||
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} }}, "
|
||||
output = output + f"{{ \"applicationName\": \"{item.app_name}\", \"image\": \"{item.icon}\", \"summary\": \"{item.summary}\", \"body\": \"{item.body}\", \"id\": {item.replaces_id} }}, "
|
||||
|
||||
else:
|
||||
output = "["+ output + f"{{ \"applicationName\": \"{item.app_name}\", \"image\": \"{item.icon}\", \"summary\": \"{item.summary}\", \"body\": \"{item.body}\", \"id\": {item.replaces_id}, \"timeout\": {item.timeout} }} ]"
|
||||
output = "["+ output + f"{{ \"applicationName\": \"{item.app_name}\", \"image\": \"{item.icon}\", \"summary\": \"{item.summary}\", \"body\": \"{item.body}\", \"id\": {item.replaces_id} }} ]"
|
||||
|
||||
|
||||
# Check if notifications(var) is empty
|
||||
if not notifications:
|
||||
output = "[]"
|
||||
os.popen(". /etc/profile; eww close floating-notifications >> /dev/null")
|
||||
|
||||
print(f"{output}", flush=True)
|
||||
|
||||
@@ -55,7 +65,7 @@ class NotificationServer(dbus.service.Object):
|
||||
|
||||
@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))
|
||||
add_popup_notification(Notification(app_name, summary, body, icon, replaces_id))
|
||||
return 0
|
||||
|
||||
@dbus.service.method("org.freedesktop.Notifications", out_signature="ssss")
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# initial history
|
||||
json_notification_history=$(dunstctl history | jq -c '.data[]' | sed 's/\\[n]/\\n/g')
|
||||
json_recent_notifications="[]"
|
||||
notification_timeout='8s'
|
||||
|
||||
while true; do
|
||||
# check history every 200ms
|
||||
sleep .2
|
||||
|
||||
if ! [[ "$json_notification_history" == "$(dunstctl history | jq -c '.data[]' | sed 's/\\[n]/\\n/g')" ]]; then
|
||||
json_notification_history="$(dunstctl history | jq -c '.data[]' | sed 's/\\[n]/\\n/g')"
|
||||
json_last_notification=$(echo $json_notification_history | jq -c ".[0]")
|
||||
|
||||
json_recent_notifications=$(echo $json_recent_notifications | jq -c ". |= [$json_last_notification] + .")
|
||||
echo $json_recent_notifications
|
||||
for (( i=0; i<$($(echo $json_recent_notifications | jq 'length')); i++ )); do
|
||||
sleep $notification_timeout
|
||||
json_recent_notifications=$(echo $json_recent_notifications | jq -c "del(.[$i])")
|
||||
echo $json_recent_notifications
|
||||
done
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
while true; do
|
||||
is_holding=$(eww get hold_volume_popup)
|
||||
if [[ $is_holding == true ]]; then
|
||||
sleep 4
|
||||
sh ./eww-window.sh close volume-popup
|
||||
eww update "hold_volume_popup=false"
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -1,22 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#!/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\""
|
||||
(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 }
|
||||
\"\")"
|
||||
(button :onclick \"hyprctl dispatch workspace $i >> /dev/null \"
|
||||
:class { $active_workspace_id == $i ? \"active\" : \"\" }
|
||||
:visible { \"$existing_workspaces\" =~ $i ? true : false }
|
||||
:tooltip \"Workspace ${i}\"
|
||||
\"\")"
|
||||
|
||||
if [ $i == 10 ]; then
|
||||
output=$output")" # closes box if last
|
||||
|
||||
Reference in New Issue
Block a user