#!/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

source ~/.config/config.env
gpgconf --dry-run --create-socketdir

#eval $(/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh)
#export SSH_AUTH_SOCK

clipmenud > $XDG_RUNTIME_DIR/clipmenud.out 2> $XDG_RUNTIME_DIR/clipmenud.err &
rm -f ~/.surf/tabbed-surf.xid
/bin/polkit-dumb-agent &
~/.local/bin/daily-update
~/.local/bin/keyboard > $XDG_RUNTIME_DIR/keyboard.out 2> $XDG_RUNTIME_DIR/keyboard.err
xrdb  ~/.config/X11/Xresources &
~/.local/bin/mailsync &

if [ "$NEXTCLOUD" = true ] ; then
  nextcloud --background &
fi
mkdir -p ~/Downloads/neomutt
if [ "$MCONNECT" = true ] ; then
    mkdir -p ~/Downloads/mconnect
    (cd ~/Downloads/mconnect; mconnect -d > $XDG_RUNTIME_DIR/mconnect 2> $XDG_RUNTIME_DIR/mconnect.err &)
fi
if [ "$ACTIVITYWATCHER" = true ] ; then
    pkill -f aw-watcher-window
    pkill -f aw-watcher-afk
    pkill -f aw-server
    aw-server &
    aw-watcher-window &
    aw-watcher-afk &
fi
mpd
mpd-mpris &
touch ~/.cache/nextcloud-track
xss-lock -- slock &
picom --no-fading-openclose &
~/.local/bin/firefox-sync
curl 'http://yeetclock/setcolor?R=136&G=192&B=208' &

dunst &

xbanish -s &

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

~/.local/bin/devmon --exec-on-drive "/sbin/notify-send '禍  drive mounted' '%l (%f) at %d '" \
    --exec-on-remove "/sbin/notify-send '禍  drive removed' '%l (%f) from %d '" \
    --exec-on-unmount  "/sbin/notify-send '禍  drive unmounted' '%l (%f) from %d '" \
    --no-unmount --no-gui &


$BROWSER &
pass 2> /dev/null > /dev/null && qtpass &

redshift -x 2> /dev/null > /dev/null
redshift -r -l "$LATLONG" > /dev/null 2> /dev/null &

tmux new-session -s weechat -d weechat > /dev/null 2> /dev/null

touch ~/.cache/dwm-restart
while [ -f /home/yigit/.cache/dwm-restart ];
do
    rm -rf /home/yigit/.cache/dwm-restart
    dwmblocks > $XDG_RUNTIME_DIR/dwmblocks.out 2> $XDG_RUNTIME_DIR/dwmblocks.err &
    exec dwm > $XDG_RUNTIME_DIR/dwm.log 2> $XDG_RUNTIME_DIR/dwm.err
    sleep 0.2
done

firefox-sync
