View Single Post
Old 08-28-2015, 09:31 PM   #17
stuguy909
Member
 
Join Date: Aug 2015
Posts: 37
Default rc5 and processes

Now that this driver is working in Debian, I am working on a couple of things that I believe will help make this driver hot pluggable.

1) The /lib/systemd/systemdisplaylink.service needs to be executed when the system hits run condition 5. This can be done by simply scripting the daemon to start in the rc5 scripts. I have a couple of ideas about accomplishing this. Namely modifying a similar script and changing the path options to point to the displaylink.service binary.


Code:
#touch /etc/init.d/displaylink
#chmod 755 /etc/init.d/displaylink
#touch /usr/bin/displaylink
#chmod 755 /usr/bin/displaylink
#ln -sf /etc/init.d/displaylink /usr/bin/displaylink
#nano /etc/init.d/displaylink
--Copy Script into /etc/init.d/displaylink--
Code:
#!/bin/sh
#/etc/init.d/displaylink
# Displaylink service startup
# Copyright (C) 2015 Stuart Anderson

### BEGIN INIT INFO
# Provides:          Displaylink.service
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     5
# Default-Stop:      0 1 2 3 4 6
# Short-Description: Start daemon at run level 5
# Description:       Enable service provided by DisplayLink.
### END INIT INFO

displaylink=/etc/init.d/displaylink
lockfile=/var/lock/displaylink

# Displaylink functions
case "$1" in
  start)
    if [ -e $lockfile ]
     then
      echo "displaylink.service already started, restarting"
      #Restart displaylink.service
      $displaylink restart
     else
      # Start displaylink.service
      echo "Starting displaylink.service"
      systemctl start displaylink.service
      systemctl status displaylink.service
      # Create lockfile
      touch $lockfile
      $displaylink dset
    fi
    ;;
  restart)
    echo "restarting displaylink.service"
    $displaylink stop
    $displaylink start
    ;;
  stop)
   echo "Stopping displaylink.service"
   systemctl stop displaylink.service
   systemctl status displaylink.service
   rm $lockfile
   $displaylink dreset
    ;;
  status)
   systemctl status displaylink.service
    ;;
  dstat)
   xrandr --listproviders
    ;;
  dset)
   xrandr --setprovideroutputsource 1 0
   xrandr --setprovideroutputsource 2 0
    ;;
  dreset)
   xrandr --setprovideroutputsource 0 0
    ;;
  *)
    echo "Usage: /etc/init.d/displaylink {start|restart|stop|status|dstat|dset|dreset}"
    exit 1
    ;;
esac

exit 0
Code:
# update-rc.d displaylink defaults
# update-rc.d displaylink start 20 5 . stop 80 0 1 2 3 4 6 .
Edit: It didn't load on startup. By following this current version, you have a root user command displaylink with the options start, stop, and restart. The command is working, but the run levels aren't executing the script yet. It's not setup right.

Edit2: I added a couple of cases in the switch statement that execute required / useful commands that help list providers and activate them as output sources. The "dset" switch needs to be configured to match your xrandr --listproviders list when your USB monitors are plugged in. This code level loads my screens. "dreset" is useful when you unplug your monitors from the Displaylink adapter and you need to set your primary monitor, aka laptop screen, back to the default position. These cases will allow me to create functions inside the /etc/init.d/displaylink script. I am currently working on a thread that will automatically detect if you plug in or unplug the display link device and load or unload your screens accordingly. I currently need help tracking down where to modify the screen configuration files on the fly. Most likely X11 configs.

Last edited by stuguy909; 08-31-2015 at 07:23 PM. Reason: no workie
stuguy909 is offline   Reply With Quote