# Resources and settings shared by screenlight components
# Version 1.1



# ***** Configuration Files ********************************************

# Location of the user configurable settings directory
CONFIG_DIR=${HOME}/.config/screenlight

# Name of the day user configurable settings file
CONFIG_FILE_DAY=screenlight-day.conf

# Name of the night user configurable settings file
CONFIG_FILE_NIGHT=screenlight-night.conf



# ***** Icons **********************************************************

# Location and name of icons
ICONS=/usr/share/pixmaps
LIB_APP=${ICONS}/screenlight.png
LIB_INFO=${ICONS}/info_blue.png



# ***** YAD Window *****************************************************

# Title in the titlebar of YAD windows
LIB_WINDOW_TITLE="Screenlight"

# Size in pixels of the border between the window edge and the dialogue
LIB_BORDER_SIZE=5

# Alignment of the dialogue text
LIB_TEXT_ALIGNMENT=left



# ***** YAD Buttons ****************************************************

# Layout of buttons
LIB_BUTTONS_POSITION=center

# Location, name, and definition of buttons
BUTTON_ICONS=/usr/local/lib/screenlight/button-icons
LIB_CANCEL=Cancel!${BUTTON_ICONS}/Cancel-16.png:1
LIB_CLOSE=Close!${BUTTON_ICONS}/Close-16.png:5
LIB_CLOSE_1=gtk-close
LIB_HELP=Help!${BUTTON_ICONS}/Help-16.png
LIB_OK=OK!${BUTTON_ICONS}/Check-16.png:0



# ***** Functions ******************************************************

lib_provide-file-from-skel()
{
   : 'Ensure a mandatory file is available in the user home file structure'
   :
   : Parameters
   : ' arg1   absolute path to the destination dir in which to put the file'
   : ' arg2   name of the file to provide'
   :
   : Result
   : ' copies a file from /etc/skel/... when one is missing from ~/.config...'
   :
   : Example
   : ' lib_provide-required-file $CONFIG_DIR "$CONFIG_FILE"'
   :
   : Note
   : ' $CONFIG_DIR $CONFIG_FILE should be set in the calling script'
   :
   : Requires
   : ' cut cp mkdir'
   
   local RELATIVE_PATH_TO_DIR
   
   # When the file is not present
   if [[ ! -f "${1}/${2}" ]]; then
   
      # Ensure the destination directory is present
      mkdir --parents  $1
      
      # Capture a relative location of the destination dir 
      # by stripping $HOME from the front of arg1
      RELATIVE_PATH_TO_DIR=$(echo $1 | cut -d'/' -f4-)
     
      # Put a copy of the file in place
      cp "/etc/skel/${RELATIVE_PATH_TO_DIR}/${2}"  "${1}/${2}"
   fi
}
