#!/bin/sh

# starting all system-wide icewm autostart programs in shutdown time
for file in /etc/X11/icewm/shutdown.d/*; do
  userfile=~/.icewm/shutdown.d/`echo $file | sed -e 's,/etc/X11/icewm/shutdown.d/,,'`
  # root can disable autostart removing 'execute' bits
  if [ -x $file ]; then
    # User-supplied programs disable system-wide programs.
    # So user can disable system-wide program
    # by touching file in ~/.icewm/shutdown.d/ with the same name
    # or even replace it with his own script.

    # skip system-wide program if user-supplied file exists.
    [ -e $userfile ] || . $file
  fi
done

# starting user-supplied icewm autostart programs in shutdown time
for file in ~/.icewm/shutdown.d/*; do
  # running user files
  # user can disable autostart removing 'execute' bits
  [ -x $file ] && . $file
done
