Class: Roebe::RXinitrc
- Inherits:
-
Base
show all
- Defined in:
- lib/roebe/classes/rxinitrc/run.rb,
lib/roebe/classes/rxinitrc/help.rb,
lib/roebe/classes/rxinitrc/rxinitrc.rb,
lib/roebe/classes/rxinitrc/constants.rb
Overview
Constant Summary
collapse
- DO_SOURCE_THE_BASHRC_FILE =
#
DO_SOURCE_THE_BASHRC_FILE
If the following constant is set to true, then we will also source the .bashrc file upon creating a new .xinitrc file.
#
true
- ARRAY_LISTING_WINDOW_MANAGERS =
#
ARRAY_LISTING_WINDOW_MANAGERS
#
%w(
fluxbox kde gnome ede
)
- ARRAY_AUTOSTART_THESE_PROGRAMS_ON_ROEBE =
#
ARRAY_AUTOSTART_THESE_PROGRAMS_ON_ROEBE
#
%w(
konsole1
xfce4-terminal
thorium2
geany
)
- HOME_DIR =
This may be required for windows.
'/home/'
- XINITRC_FILE =
"#{HOME_DIR}/.xinitrc"
- START_XSERVER =
false
- APPS_FILE =
"#{ENV['MY_LINUX']}/FLUXBOX/apps"
- ARRAY_AUTOSTART_THESE_PROGRAMS_WHEN_USING_THE_MATE_DESKTOP =
#
ARRAY_AUTOSTART_THESE_PROGRAMS_WHEN_USING_THE_MATE_DESKTOP
To automatically create these .desktop files, do this:
rxinit mate
#
YAML.load_file(FILE_AUTOSTART_THESE_PROGRAMS)
- ARRAY_WE_CAN_GENERATE_THESE_FILES =
#
ARRAY_WE_CAN_GENERATE_THESE_FILES
Ideally keep this array sorted, even though this is not a hugely important requirement.
#
%w(
afterstep
cinnamon
ede
enlightenment
fluxbox
fvwm
gnome
icewm
ion
kde
kde5
mate
openbox
pawm
pekwm
ratpoison
subtle
xfce
windowmaker
wmii
).sort
Constants inherited
from Base
Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE
Instance Method Summary
collapse
Methods inherited from Base
#actions, #append_this_onto_that_file, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #burlywood, #call_next, #chdir, #cheerful_guy, #cliner, #complex_esystem, #convert_global_env, #copy_directory, #cornflowerblue, #create_directory, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkkhaki, #darkslateblue, #deeppink, #delete_symlink, #do_not_use_the_base_colours, #do_use_the_base_colours, #e, #ecomment, #editor_to_use?, #efancy, #eimp, #emphasis, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esteelblue, #etomato, #ewarn, #exit_program, #firebrick, #get_current_day, #get_current_month, #get_files_and_directories, #get_files_from, #get_german_name_for_this_weekday, #gold, #green, #grey, #hh_mm_ss, #hh_mm_ss_day_month_year, #home_dir?, #home_directory_of_user_x?, #infer_the_namespace, #internal_hash?, #is_a_directory?, #is_a_file?, #is_a_jpg_file?, #is_an_image_file?, #is_archive?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_on_roebe?, #is_on_windows?, #is_studium_available?, #is_symlink?, #is_this_a_ruby_file?, #is_video_file?, #iso_encoding?, #le, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lightsteelblue, #lime, #limegreen, #localhost_to_data, #log_directory?, #main_encoding?, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mkdir_p, #mv, #n_days_in_this_month, #n_pages_in_this_pdf_file?, #namespace?, #no_file_exists_at, #ogrey, #olive, #olivedrab, #open_in_browser, #opne, #opnesystem, #orange, #orchid, #orev, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #project_base_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #remove, #remove_directory, #remove_file, #rename_kde_konsole_tab, #replace_localhost_with_data, #report_pwd, #require_rescue, #reset_the_internal_hash, #return_all_directories_from_this_directory, #return_all_files_from_this_directory, #return_current_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #roebe_log_directory?, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #set_xorg_buffer, #sfancy, #sfile, #show_help, #silent_redirection?, #simp, #simple_esystem, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #string_italic, #swarn, #symlink, #teal, #temp_dir?, #to_camelcase, #to_counted_hash, #tomato, #touch, #try_to_require_the_beautiful_url_gem, #try_to_require_the_html_template, #try_to_require_the_open_gem, #try_to_require_the_program_information_gem, #try_to_require_the_xorg_buffer, #use_colours?, #verbose_truth, #weekday?, #word_wrap, #write_what_into, #yellow
#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments
Constructor Details
#initialize(generate_for_this_application, run_already = true) ⇒ RXinitrc
#
initalize
Pass one argument to it.
#
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 27
def initialize(
generate_for_this_application,
run_already = true
)
reset
set_append_this_string(
generate_for_this_application
)
run if run_already
end
|
Instance Method Details
#add(i = N) ⇒ Object
434
435
436
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 434
def add(i = N)
@_ << i
end
|
#add_default_xterm_on_startup ⇒ Object
#
add_default_xterm_on_startup
#
488
489
490
491
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 488
def add_default_xterm_on_startup
@_ << +'# Run an instance of xterm, on startup'+N++
'xterm &'+N+N
end
|
#add_exec_line ⇒ Object
503
504
505
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 503
def add_exec_line
@_ << 'exec '+@append_this_string.to_s end
|
#add_mouse_acceleration ⇒ Object
#
add_mouse_acceleration
#
480
481
482
483
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 480
def add_mouse_acceleration
@_ << +'# Add mouse acceleration'+N++
'xset m 7 2'+N+N
end
|
#autogenerate_fluxbox_files ⇒ Object
#
autogenerate_fluxbox_files
#
#check_whether_we_should_source_the_bashrc_file ⇒ Object
#
check_whether_we_should_source_the_bashrc_file
#
441
442
443
444
445
446
447
448
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 441
def check_whether_we_should_source_the_bashrc_file
if DO_SOURCE_THE_BASHRC_FILE
prepend 'source $HOME/.bashrc'+N+N if is_on_roebe?
prepend 'source /AUTOGENERATED/aliases_rc'+N+N
end
end
end
|
#consider_adding_autostart_these_programs_if_on_roebe ⇒ Object
#
consider_adding_autostart_these_programs_if_on_roebe
#
510
511
512
513
514
515
516
517
518
519
520
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 510
def consider_adding_autostart_these_programs_if_on_roebe
if is_on_roebe?
ARRAY_AUTOSTART_THESE_PROGRAMS_ON_ROEBE.each {|this_program|
case this_program
when 'konsole1'
this_program = 'konsole --tabs-from-file /home/x/programming/ruby/src/roebe/lib/roebe/shell_scripts/konsole_tabs.sh &'
end
@_ << this_program+' &'+N+N
}
end
end
|
#consider_adding_keyboard_entry ⇒ Object
#
consider_adding_keyboard_entry
Add our keyboard model here.
#
92
93
94
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 92
def consider_adding_keyboard_entry
@_ << 'setxkbmap -model pc105 -layout de -variant nodeadkeys -v 10'+N+N
end
|
#consider_aliasing_kp_enter_to_return ⇒ Object
#
consider_aliasing_kp_enter_to_return
#
60
61
62
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 60
def consider_aliasing_kp_enter_to_return
@_ << 'xmodmap -e "keysym KP_Enter = Return"'+N+N
end
|
#consider_running_postcreation_actions ⇒ Object
#
consider_running_postcreation_actions
Right now we only copy the apps file, if we use fluxbox.
#
392
393
394
395
396
397
398
399
400
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 392
def consider_running_postcreation_actions
if @append_this_string.include? 'fluxbox'
fluxbox_home_dir = HOME_DIR+'.fluxbox/'
mkdir fluxbox_home_dir
target = fluxbox_home_dir+File.basename(APPS_FILE)
copy_file(APPS_FILE, target)
end
end
|
#copy_file(from, to) ⇒ Object
405
406
407
408
409
410
411
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 405
def copy_file(from, to)
if File.exist? to
opne 'Can not copy as '+sfile(to)+' already exists.'
else
FileUtils.cp(from, to)
end
end
|
#create_these_desktop_files(i = ARRAY_AUTOSTART_THESE_PROGRAMS_WHEN_USING_THE_MATE_DESKTOP) ⇒ Object
#
create_these_desktop_files
#
#create_xinitrc_file(i = @store_where) ⇒ Object
Also known as:
create_xinitrc
#
create_xinitrc_file
This method will simply create our .xinitrc file.
#
418
419
420
421
422
423
424
425
426
427
428
429
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 418
def create_xinitrc_file(i = @store_where)
check_whether_we_should_source_the_bashrc_file
opne rev+'Created file at '+sfile(i)+rev+
' with last line content being `'+
Colours::LIGHTBLUE+@_.split(N)[-1].to_s+
rev+'`'+rev+'.'
save_what_into(@_, i)
if is_on_roebe?
opne 'Hint: the autostart directory is at '+
sdir(home_dir?.to_s+'.config/autostart/')
end
end
|
#determine_which_wm ⇒ Object
#
determine_which_wm
This will determine which wm we will use.
#
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 112
def determine_which_wm
if @append_this_string == 'random'
@append_this_string = ARRAY_LISTING_WINDOW_MANAGERS.sample
end
case @append_this_string when 'weston'
@append_this_string = 'weston-launch'
when 'mate','6'
@append_this_string = 'mate-session'
if is_on_roebe?
opne rev+'Entries will be used from this file:'
e
e sfile(" #{FILE_AUTOSTART_THESE_PROGRAMS}")
e
end
create_these_desktop_files(
ARRAY_AUTOSTART_THESE_PROGRAMS_WHEN_USING_THE_MATE_DESKTOP
)
when 'ice','i','icewm','eis'
@append_this_string = 'icewm-session'
when /^-?-?plasma$/i,'kde5',/^kde(_|-)?plasma$/,
'kde','k'
@append_this_string = 'startplasma-x11'
when 'lxqt','LXQT','LXQt'
@append_this_string = 'startlxqt'
when 'kde4','4'
@append_this_string = 'startkde' when 'lumina'
@append_this_string = 'start-lumina-desktop'
when 'pantheon'
@append_this_string = 'exec cerbere'
when 'fluxbox','f','flux'
autogenerate_fluxbox_files if is_on_roebe?
@append_this_string = 'fluxbox -log ~/.fluxbox/log'
when 'deepin','deep'
@append_this_string = 'startdde'
when /xfce/,
'xfc',
'x'
@append_this_string = 'startxfce4'
when 'cin',
'cinnamon',
'cinna',
'ci'
@append_this_string = 'cinnamon-session'
when 'openbox','o'
@append_this_string = 'openbox'
when 'fvwm','crystal','c'
@append_this_string = 'fvwm' when 'ion','ion3'
@append_this_string = 'ion3'
when 'gnome','g','gdm','gnom','dbus','gnomex' @append_this_string = '/usr/bin/dbus-launch --exit-with-session gnome-session'
@append_this_string = 'gnome-session'
@append_this_string = 'gnome-session --session=classic-gnome'
when 'enlightenment','e','e17','enlight','buddha','enl'
@append_this_string = 'enlightenment_start'
when 'wmaker','wm','w','windowmaker','widowmaker'
@append_this_string = 'wmaker'
when 'rat','ratpoison','rats','r','ratten','ratpoi'
@append_this_string = 'ratpoison'
when 'pekwm','pek','p'
@append_this_string = 'pekwm'
when 'ede','ed','windows'
@append_this_string = 'startede'
when 'wmii','wmi'
@append_this_string = 'wmii'
when 'afterstep','after','a'
@append_this_string = 'afterstep'
when 'pawm','paw','pwm'
@append_this_string = 'pawm'
when 'subtle','5'
@append_this_string = 'subtle'
else @append_this_string = 'openbox' end
end
|
#feedback_help(then_exit = true) ⇒ Object
#
feedback_help (help tag)
Use this to feedback help.
To invoke this method, try:
rxinitrc --help
#
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/roebe/classes/rxinitrc/help.rb', line 21
def feedback_help(
then_exit = true
)
opne 'Help was requested. This class can generate a startup '\
'file for these'
opne 'applications:'
e
ARRAY_WE_CAN_GENERATE_THESE_FILES.each {|file|
e " - #{tomato(file)}"
}
e
e 'You can also query which desktop environment / window manager '
e 'will be started, via:'
e
e ' --active?'
e
exit if then_exit
end
|
#find_the_name_for_this_application(i) ⇒ Object
#
find_the_name_for_this_application
This method will try to find the corresponding name for the desktop environment or window manager in “use”.
#
330
331
332
333
334
335
336
337
338
339
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 330
def find_the_name_for_this_application(i)
case i
when 'startkde'
i = 'KDE4'
end
i
end
|
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 344
def (i)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i
when /^-?-?active\??$/i
show_which_application_will_be_started_via_xinitrc
exit
when /^-?-?create(-|_| )?these(-|_| )?desktop(-|_| )?files$/
create_these_desktop_files
exit
when /^--help$/i
feedback_help
end
end
end
|
460
461
462
463
464
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 460
def opnn
super(
namespace?, :display_only_last_name )
end
|
#prepend(i) ⇒ Object
453
454
455
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 453
def prepend(i)
@_.prepend(i)
end
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 41
def reset
super()
infer_the_namespace
_ = '# =========================================================================== #
# Set black background / Setze schwarzen Hintergrund::
# =========================================================================== #
xsetroot -solid black
'
@_ = ''.dup
consider_adding_keyboard_entry
consider_aliasing_kp_enter_to_return
@_ << _ @_ << N
set_store_where(XINITRC_FILE)
end
|
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/roebe/classes/rxinitrc/run.rb', line 14
def run
determine_which_wm
add_mouse_acceleration
add_default_xterm_on_startup
consider_adding_autostart_these_programs_if_on_roebe
add_exec_line
create_xinitrc_file
consider_running_postcreation_actions
start_xserver if start_xserver?
end
|
#set_append_this_string(i) ⇒ Object
#
set_append_this_string
#
74
75
76
77
78
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 74
def set_append_this_string(i)
(i)
i = i.first.to_s.dup if i.is_a? Array
@append_this_string = i
end
|
#set_store_where(i = XINITRC_FILE) ⇒ Object
99
100
101
102
103
104
105
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 99
def set_store_where(
i = XINITRC_FILE
)
i = i.dup if i.frozen?
i.squeeze!('/')
@store_where = i
end
|
#show_which_application_will_be_started_via_xinitrc ⇒ Object
#
show_which_application_will_be_started_via_xinitrc
To invoke this method from the commandline, do:
rxinitrc --active?
#
310
311
312
313
314
315
316
317
318
319
320
321
322
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 310
def show_which_application_will_be_started_via_xinitrc
_ = @store_where
if File.exist? _
this_application = File.readlines(_).reject {|line| line.strip.empty? }.last.strip
this_application.sub!(/exec /,'')
e 'This application will be started:'
e
e ' '+sfancy(
find_the_name_for_this_application(this_application)
)
e
end
end
|
#start_xserver ⇒ Object
#
start_xserver
Starts xserver. Not always useful though. :P
#
383
384
385
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 383
def start_xserver
system 'startx'
end
|
#start_xserver? ⇒ Boolean
83
84
85
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 83
def start_xserver?
START_XSERVER
end
|
496
497
498
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 496
def
'# ============================================================================ #'+N
end
|
#store_where? ⇒ Boolean
Also known as:
store_where
67
68
69
|
# File 'lib/roebe/classes/rxinitrc/rxinitrc.rb', line 67
def store_where?
@store_where
end
|