class Autostart

#
#

require 'autostart/version/version.rb'

#

Constants

#

Which entries should be symlinked for KDE.

If you do not want to have this entry, simply remove it from the constant.

#
#

Use xchat, bluefish, konsole and mrxvt.

#
DEFAULT_COLOUR
#

DEFAULT_COLOUR

#
DEFAULT_INPUT
#

DEFAULT_INPUT

#
FIREFOX_BINARY
#

FIREFOX_BINARY

#
HOME_DIR
#

HOME_DIR

#
KDE_AUTOSTART
#

KDE_AUTOSTART

#
LINUX
#

LINUX

#
SOFFICE_BINARY
#

SOFFICE_BINARY

For libreoffice.

#
SYSBIN
#

SYSBIN

#
VERSION
#

Autostart::VERSION

#

Public Class Methods

autostart_kde() click to toggle source
#

Autostart.autostart_kde

#
# File lib/autostart/autostart.rb, line 276
def self.autostart_kde
  self.new(:kde)
end
new( what = 'default' ) click to toggle source
#

initialize

#
# File lib/autostart/autostart.rb, line 33
def initialize(
    what = 'default'
  )
  reset
  autostart_what(what) if what
end
run(i = ARGV) click to toggle source
#

Autostart.run

#
# File lib/autostart/autostart.rb, line 283
def self.run(i = ARGV)
  self.new(i)
end

Public Instance Methods

autostart_kde() click to toggle source
#

autostart_kde (kde tag)

To invoke this method, do:

autostart --kde
#
# File lib/autostart/autostart.rb, line 185
def autostart_kde
  show_header :kde
  # mkdir HSS['KDE_AUTOSTART']
  ensure_that_this_directory_exists KDE_AUTOSTART
  mkdir '~/.kde/share/config/'
  copy '$LINUX/KDE/konsolerc','~/.kde/share/config/'
  ARRAY_SYMLINK_THESE_ENTRIES_FOR_KDE.each {|entry|
    symlink(entry+' $KDE_AUTOSTART')
  }
end
autostart_mate( use_these_programs = YAML.load_file( '/Users/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/roebe/lib/roebe/yaml/'\ 'autostart_these_programs.yml' ) ) click to toggle source
#

autostart_mate

#
# File lib/autostart/autostart.rb, line 199
def autostart_mate(
    use_these_programs = YAML.load_file(
      '/Users/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/roebe/lib/roebe/yaml/'\
      'autostart_these_programs.yml'
    )
  )
  show_header :mate
  home_dir = HOME_DIR+'.config/autostart'
  mkdir home_dir
  use_these_programs.each {|this_file|
    Roebe::CreateDesktopFile.new(this_file)
  }
end
autostart_what(i = DEFAULT_INPUT) click to toggle source
#

autostart_what

#
# File lib/autostart/autostart.rb, line 234
def autostart_what(i = DEFAULT_INPUT)
  i = DEFAULT_INPUT if i.nil?
  i = i.first if i.is_a? Array # Fetch first entry if it is an Array.
  case i.to_s # case tag
  # ======================================================================= #
  # === autostart help
  # ======================================================================= #
  when /^-?-?help/
    show_help
    exit
  # ======================================================================= #
  # === autostart mate
  # ======================================================================= #
  when /^-?-?mate$/
    autostart_mate
  # ======================================================================= #
  # === autostart xfce
  # ======================================================================= #
  when /^-?-?xfce$/,'default','' # This is the default since August 2013.
    autostart_xfce
  # ======================================================================= #
  # === autostart kde
  # ======================================================================= #
  when /^-?-?kde$/
    autostart_kde
  else
    opn; e 'Not found `'+simp(i)+'` in the list of available entries.'
    opn; e 'It is probably not registered.'
  end
  consider_reporting_missing_entries_to_the_user
end
Also aliased as: run
autostart_xfce( i = ARRAY_SYMLINK_THESE_ENTRIES_FOR_XFCE ) click to toggle source
#

autostart_xfce (xfce tag)

This will usually default to programs such as:

xchat, bluefish, konsole and mrxvt.
#
# File lib/autostart/autostart.rb, line 219
def autostart_xfce(
    i = ARRAY_SYMLINK_THESE_ENTRIES_FOR_XFCE
  )
  show_header :xfce
  # home_dir = '~/.config/autostart'
  home_dir = HOME_DIR+'.config/autostart'
  mkdir home_dir
  i.each {|entry|
    symlink(entry+' '+home_dir)
  }
end
consider_reporting_missing_entries_to_the_user() click to toggle source
#

consider_reporting_missing_entries_to_the_user

#
# File lib/autostart/autostart.rb, line 51
def consider_reporting_missing_entries_to_the_user
  unless @array_these_symlinks_were_not_found.empty?
    e; opn; e 'We did find some missing entries. Perhaps you '\
              'may wish to correct these:'
    e
    @array_these_symlinks_were_not_found.each {|entry|
      e simp("  #{entry}")
    }; e
  end
end
copy(from, to) click to toggle source
#

copy

#
# File lib/autostart/autostart.rb, line 88
def copy(from, to)
  from = ConvertGlobalEnv[from] if from.include? '$'
  to   = ConvertGlobalEnv[to]   if to.include? '$'
  from = File.expand_path(from)
  to   = File.expand_path(to)
  FileUtils.copy(from, to)
end
ensure_that_this_directory_exists(i)
Alias for: mkdir
mkdir(i) click to toggle source
#

mkdir

#
# File lib/autostart/autostart.rb, line 65
def mkdir(i)
  i = File.expand_path(i) if i.include? '~' # If includes ~, use File.expand_path
  FileUtils.mkdir_p(i) unless File.exist?(i)
end
orange(i) click to toggle source
#

orange

#
# File lib/autostart/autostart.rb, line 269
def orange(i)
  Colours.orange(i)
end
output_header() click to toggle source
#

output_header (cliner tag, liner tag)

#
# File lib/autostart/autostart.rb, line 160
def output_header
  e '=' * 80
end
red() click to toggle source
#

red

#
# File lib/autostart/autostart.rb, line 81
def red
  Colours::RED
end
remove_file(i) click to toggle source
#

remove_file

#
# File lib/autostart/autostart.rb, line 73
def remove_file(i)
  opn; e red+'Removing file '+sfile(i)+red+' now.' if File.exist?(i)
  File.delete(i) if File.file?(i)
end
reset() click to toggle source
#

reset

#
# File lib/autostart/autostart.rb, line 43
def reset
  @array_these_symlinks_were_not_found = []
  @be_verbose = true
end
run(i = DEFAULT_INPUT)
Alias for: autostart_what
show_header( for_this_program = :xfce ) click to toggle source
#

show_header

#
# File lib/autostart/autostart.rb, line 143
def show_header(
    for_this_program = :xfce
  )
  case for_this_program
  when :xfce
    for_this_program = 'XFCE'
  when :kde
    for_this_program = 'KDE'
  end
  output_header
  opn; e "Autostart for #{orange(for_this_program)}."
  output_header
end
show_help() click to toggle source
#

show_help

#
# File lib/autostart/autostart.rb, line 167
def show_help
  e 'This class (class Autostart) allows you to "autostart" some '\
    'applications in different DE/WMs.'
  e
  e 'Available autostart actions are:'
  e
  e '  - xfce'
  e '  - kde'
  e '  - mate'
  e
end