class Autostart
#¶ ↑
#¶ ↑
require 'autostart/version/version.rb'
#¶ ↑
Constants
- ARRAY_SYMLINK_THESE_ENTRIES_FOR_KDE
#¶ ↑
ARRAY_SYMLINK_THESE_ENTRIES_FOR_KDE
¶ ↑Which entries should be symlinked for KDE.
If you do not want to have this entry, simply remove it from the constant.
#¶ ↑
- ARRAY_SYMLINK_THESE_ENTRIES_FOR_XFCE
#¶ ↑
ARRAY_SYMLINK_THESE_ENTRIES_FOR_XFCE
¶ ↑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
new( what = 'default' )
click to toggle source
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
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
Also aliased as: ensure_that_this_directory_exists
orange(i)
click to toggle source
output_header()
click to toggle source
red()
click to toggle source
remove_file(i)
click to toggle source
reset()
click to toggle source
show_header( for_this_program = :xfce )
click to toggle source
show_help()
click to toggle source
symlink(i)
click to toggle source
#¶ ↑
symlink¶ ↑
This method accepts only one argument and will split it based on ' '.
File.symlink(real_existing_location, new_location)
#¶ ↑
# File lib/autostart/autostart.rb, line 102 def symlink(i) # Expects string input. real_existing_location, new_location = i.split ' ' if real_existing_location.include? '$' # We solve this very simply without regex. last_position = real_existing_location.index('/') real_value = ENV[real_existing_location[1, last_position-1]].dup real_existing_location = real_value+real_existing_location[last_position..-1] end if new_location.include? '$' new_location = ConvertGlobalEnv.convert new_location end new_location = File.expand_path(new_location) if new_location.include? '~' filename = File.basename(real_existing_location) new_location << '/'+filename if File.symlink?(new_location) readlink = File.readlink(new_location) remove_file(readlink) unless File.exist?(readlink) end remove_file(new_location) if File.exist? new_location if File.exist?(real_existing_location) opn; e 'Trying to symlink '+sfile(real_existing_location)+ ' to '+sfile(new_location)+' now.' unless File.exist? new_location File.symlink(real_existing_location, new_location) else opn; e 'Can not symlink because '+sfile(new_location)+' does not exist.' end else if @be_verbose opn; e 'Trying to symlink '+sfile(real_existing_location)+ ' to '+sfile(new_location) opn; e 'but the file '+sfile(real_existing_location)+' does not '\ 'exist, thus we skip this action.' @array_these_symlinks_were_not_found << real_existing_location end end end