#!/bin/bash

pkill -f clipmenud
pkill -9 devmon
pkill -f "bash /sbin/clipmenud"
pkill -f "/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh"
pkill -f devmon

echo "$DBUS_SESSION_BUS_ADDRESS" > /tmp/bus-session

rm -rf $XDG_RUNTIME_DIR/day_cache
export XSESSION_PID="$$"

source ~/.config/config.env


pactl upload-sample /usr/share/sounds/freedesktop/stereo/bell.oga x11-bell
pactl load-module module-x11-bell sample=x11-bell display=$DISPLAY
xset b 100
xset dpms 600 600 600
xrdb  ~/.config/X11/Xresources &

restarted=0
while true;
do
    if [ $restarted = 0 ]; then
        restarted=1
    else
        notify-send -a " Desktop Manager" "Dwm Restarted"
    fi

    dwm > $XDG_RUNTIME_DIR/dwm.log 2> $XDG_RUNTIME_DIR/dwm.err
    sleep 0.5
done
