#!/bin/sh

# apply xresources
xrdb -merge ~/.icewm/xrescolors
xrdb -merge ~/.icewm/xres

# volume tray
~/.icewm/programs/volumecontrol/volume &

# mtpd script is a bit unreliable
#~/.icewm/mtpd&

# desktop icons using idesk
idesk &

sleep 0.2

# safely remove tray
~/.icewm/programs/explorer/ejecttray/ejecttray &
sleep 0.1
#volumeicon &

# clipboard manager (parcellite)
parcellite &
#sleep 0.1
xscreensaver -nosplash &
#xautolock -time 10 -locker "~/.icewm/programs/lock/lock2k" &

# network tray
cd "$HOME/.icewm/cfg/nettray"
for i in *
do
	~/.icewm/programs/nettray/nettray $i &
	sleep 0.1
done

# keyboard layout switcher (a bit buggy)
~/.icewm/programs/kbswitch/kbswitch &
sleep 0.1

#sleep 2

# battery icon
cbatticon -x "$HOME/.icewm/programs/backlight/backlight" \
-o "sh -c 'nohup $HOME/.icewm/programs/panel/batterywarning low >/dev/null 2>&1 &'" -l 20 \
-c "sh -c 'nohup $HOME/.icewm/programs/panel/batterywarning critical >/dev/null 2>&1 &'" -r 10 &

cd "$HOME"

# animated background manager
~/.icewm/programs/animbg/animbg &
sleep 2

# restart icewm to fix frozen tray icons
icewm -r

# play startup sound
aplay $ICE2KSYS_SOUND_LOGON &
~/.icewm/programs/welcome/welcomewrap &
#xsnow -nomenu -wantwindow transparent &

#telegram-desktop -startintray &
