eww: add new tiles to control-center, new notification popup, new styles for a lot of widgets

This commit is contained in:
retrozinndev
2025-01-07 16:26:20 -03:00
parent 435b222e03
commit c505ecf4cf
43 changed files with 802 additions and 319 deletions
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# This script reloads eww configuration and updates
# window status variables, used in eww-window.sh
# script. Avoids issues with widgets that use status
# variables to dinamically change their content.
# ----------
# Licensed under the MIT License
# Made by retrozinndev (João Dias)
# From https://github.com/retrozinndev/Hyprland-Dots
# TODO
open_windows=$(eww active-windows | awk -F: '{ print $1 }' | sed -e 's/ /\\[n]/g')
echo $open_windows
#for window in $()
+3 -3
View File
@@ -44,7 +44,7 @@ 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
if ! [[ $(eww active-windows) =~ "$2" ]]; then
eww open "$2"
eww update "window_state_$2=open"
else
@@ -54,7 +54,7 @@ Licensed under the MIT License, as in retrozinndev's Hyprland-Dots repo."
--close | close)
check_if_empty $2 "WINDOW_NAME"
if [[ $(eww get "window_state_$2") == "open" ]]; then
if [[ $(eww active-windows) =~ "$2" ]]; then
eww close "$2"
eww update "window_state_$2=closed"
else
@@ -64,7 +64,7 @@ Licensed under the MIT License, as in retrozinndev's Hyprland-Dots repo."
--toggle | toggle)
check_if_empty $2 "WINDOW_NAME"
if [[ $(eww get "window_state_$2") == "closed" ]]; then
if ! [[ $(eww active-windows) =~ "$2" ]]; then
eww open "$2"
eww update "window_state_$2=open"
else
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -e
pidfile="$HOME/.cache/night-light.pid"
temperature=4500 # in K
# run only if pid file does not exist
if ! [[ -f $pidfile ]]; then
touch $pidfile
hyprsunset -t $temperature &
_pid=$!
echo -e $_pid > $pidfile
wait $_pid && rm -f $pidfile
else
echo "There's already an instance running! Mistake? Delete \"~/.cache/night-light.pid\"."
exit 1
fi
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
lockfile=$HOME/.cache/notification-history.lock
json_history_file=$HOME/.cache/notification-history.json
if ! [[ -f $lockfile ]]; then
echo "{ \"history\": [] }" > $json_history_file
fi
+65 -10
View File
@@ -1,18 +1,73 @@
#!/usr/bin/env bash
# initial notification history
json_initial_history=$(makoctl history | jq -c '.data[]' | sed -e 's/\\[n]/\\n/g' -e 's/&/&/g')
echo $json_initial_history
# A notification logger, saves notifications inside
# a file instead of saving on memory! file is located
# in `~/.cache/notification-history.json`.
# -----------
# Licensed under the MIT License
# Made by retrozinndev (João Dias)
# From https://github.com/retrozinndev/Hyprland-Dots
set -e
json_history_file="$HOME/.cache/notification-history.json"
lock_file="$HOME/.cache/notification-history.lock"
# get max entries from mako file
max_entries=$(cat $HOME/.config/mako/config | grep "max-history=" | awk -F= '{ print $2 }')
touch $json_history_file
function Init_history_file() {
if [[ $(cat $json_history_file) == "" ]]; then
echo -e "{\"history\":[]}" > $json_history_file
fi
}
function Check_history_file() {
if ! [[ -f $json_history_file ]]; then
touch $json_history_file
fi
}
function Treat_specials() {
echo $@ | sed -e 's/\\[n]/\\n/g' -e 's/&/&/g'
}
Check_history_file
Init_history_file
json_latest_notification="$(makoctl history | jq -c '.data[][0]')"
while true; do
# watch history every 200ms
sleep .2
sleep .1
if ! [[ -f $lock_file ]]; then
json_actual_latest="$(makoctl history | jq -c '.data[][0]')"
if ! [[ $json_actual_latest == $json_latest_notification ]]; then
if [[ $(echo $(Treat_specials $json_actual_latest) | jq -c '.id.data') == $(echo $(Treat_specials $json_latest_notification) | jq -c '.id.data') ]]; then
if [[ $(echo $(Treat_specials $json_actual_latest) | jq -c '.summary.data') == $(echo $(Treat_specials $json_latest_notification) | jq -c '.summary.data') ]]; then
continue
else
sh $HOME/.config/eww/scripts/notification-remove.sh $(echo $(Treat_specials $json_latest_notification) | jq -c '.id.data') &
fi
fi
# frequently updated history variable
json_history=$(makoctl history | jq -c '.data[]' | sed -e 's/\\[n]/\\n/g' -e 's/&/&/g')
Check_history_file
Init_history_file
json_latest_notification=$(makoctl history | jq -c '.data[][0]')
json_first_notification=$(jq -c ".history[$(jq -c '.history | length - 1' $json_history_file)]" $json_history_file)
if ! [[ "$json_initial_history" == "$json_history" ]]; then
json_initial_history="$json_history"
echo "$json_initial_history"
if ! [[ $(makoctl mode) =~ "dnd" ]]; then
sh $HOME/.config/eww/scripts/notification-popup.sh "$(Treat_specials $json_latest_notification)" &
fi
if [[ $(jq -c ".history | length" $json_history_file) == $max_entries ]]; then
sh $HOME/.config/eww/scripts/notification-remove.sh $(echo $json_first_notification | jq -c '.id.data')
fi
json_output=$(jq -c ".history |= [$(Treat_specials $json_latest_notification)] + ." $json_history_file)
echo -e "$json_output" > $json_history_file
fi
fi
done
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Removes notification from popup by id provided
# in arg1.
# ---------
# Licensed under the MIT License
# Made by retrozinndev (João Dias)
# From https://github.com/retrozinndev/Hyprland-Dots
if ! [[ $1 == "" ]]; then
json_popup_notifications=$(eww get json_popup_notifications)
if [[ $(eww get json_popup_notifications | jq -c '.notifications | length') == 1 ]]; then
sh $HOME/.config/eww/scripts/eww-window.sh close floating-notifications >> /dev/null
fi
eww update "json_popup_notifications=$(echo $json_popup_notifications | jq -c "del(.notifications[] | select(.id.data == $1))")"
exit 0
fi
echo "[error] Notification Id not provided!"
exit 1
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# This scripts receives a notification from arg1,
# in a json format, displays in eww, counting
# down depending on notification urgency and
# removes the notification from json.
# Timeout in seconds
# When set to 0, notification will disappear
# only when hovering it.
timeout_low=3
timeout_normal=6
timeout_critical=0
if ! [[ $@ == "" ]]; then
# Urgency levels:
# Low: 0, Normal: 1, Critical: 2
urgency=$(echo $@ | jq -c ".urgency.data")
id=$(echo $@ | jq -c ".id.data")
json_popup_notifications="$(eww get json_popup_notifications)"
json_notification=$(echo $@ | jq -c '.')
if [[ $json_popup_notifications == "" ]]; then
eww update "json_popup_notifications="'{"notifications":[]}' >> /dev/null
json_popup_notifications='{"notifications":[]}'
fi
eww update "json_popup_notifications=$(echo $json_popup_notifications | jq -c ".notifications |= [$json_notification] + .")" >> /dev/null
sh $HOME/.config/eww/scripts/eww-window.sh open floating-notifications >> /dev/null
# Critical urgency is handled by eww, no need to count down
case $urgency in
0*)
sleep $timeout_low
;;
1*)
sleep $timeout_normal
;;
esac
if ! [[ $urgency == 2 ]]; then
sh $HOME/.config/eww/scripts/notification-popup-remove.sh "$id" &
fi
fi
exit 0
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Removes notification from history file by
# id provided in arg1.
# ---------
# Licensed under the MIT License
# Made by retrozinndev (João Dias)
# From https://github.com/retrozinndev/Hyprland-Dots
json_history_file="$HOME/.cache/notification-history.json"
lock_file="$HOME/.cache/notification-history.lock"
if [[ -f $HOME/.cache/notification-history.json ]] && ! [[ $1 == "" ]]; then
touch $lock_file
json_updated_history=$(jq -c "del(.history[] | select(.id.data == $1))" $json_history_file)
echo -e $json_updated_history > $json_history_file
rm -f $lock_file
else
echo "[error] Notification history not reachable or id not provided"
exit 1
fi
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# This script watches notification file changes
# and output file contents.
# -----------
# Licensed under the MIT License
# Made by retrozinndev (João Dias)
# From https://github.com/retrozinndev/Hyprland-Dots
set -e
json_history_file="$HOME/.cache/notification-history.json"
if ! [[ -f $json_history_file ]]; then
echo -e "{\"history\":[]}" > $json_history_file
fi
json_history="$(cat $json_history_file)"
echo $json_history
while true; do
sleep .1
json_newest_history=$(cat $json_history_file)
if ! [[ "$json_history" == "$json_newest_history" ]]; then
json_history="$json_newest_history"
echo $json_history
fi
done
exit 0
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -e
dest="$HOME/Recordings"
if ! [[ $(xdg-user-dir VIDEOS) == "" ]]; then
dest="$(xdg-user-dir VIDEOS)/Recordings"
fi
lock="$HOME/.cache/recording.lock"
pidfile="$HOME/.cache/recording.pid"
ext="mp4" # mp4,mkv...
filename=$(date +"%Y-%m-%d-%H%M%S_rec.$ext")
mkdir -p $dest
# run only if lockfile does not exist
if ! [[ -f $lock ]]; then
touch $lock
wf-recorder -f "$dest/$filename" &
rec_pid=$!
echo -e $rec_pid > $pidfile
wait $rec_pid && (
notify-send -a "Screen Recorder" "Recording Done" "The screen recording has been saved as '$dest/$filename'!"
rm -f $lock $pidfile
)
else
notify-send -a "Screen Recorder" "Recording Error" "There's already an instance running! Mistake? Delete $lock and $pidfile."
exit 1
fi
@@ -1,24 +0,0 @@
#!/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
+1 -2
View File
@@ -1,8 +1,7 @@
#!/usr/bin/env bash
while true; do
is_holding=$(eww get hold_volume_popup)
if [[ $is_holding == true ]]; then
if [[ $(eww get hold_volume_popup) == true ]]; then
sleep 4
sh ./eww-window.sh close volume-popup
eww update "hold_volume_popup=false"
+4 -3
View File
@@ -1,8 +1,9 @@
#!/usr/bin/env bash
print_workspaces_literal() {
active_workspace_id=$(hyprctl -j activeworkspace | jq .id | xargs)
existing_workspaces=$(hyprctl -j workspaces | jq .[].id | xargs)
active_workspace_id=$(hyprctl -j activeworkspace | jq -c '.id' | xargs)
json_workspaces=$(hyprctl -j workspaces | jq -c '.')
existing_workspaces=$(echo $json_workspaces | jq -c '.[].id' | xargs)
output="
(box :space-evenly false
@@ -11,7 +12,7 @@ print_workspaces_literal() {
for i in {1..10}; do
output=$output"
(button :onclick \"hyprctl dispatch workspace $i >> /dev/null \"
:class { $active_workspace_id == $i ? \"active\" : \"\" }
:class \"\${ $active_workspace_id == $i ? 'active' : '' } $( [[ $(echo $json_workspaces | jq -c ".[$i - 1].name") =~ "special:" ]] && echo 'special' )\"
:visible { \"$existing_workspaces\" =~ $i ? true : false }
:tooltip \"Workspace ${i}\"
\"\")"