Class: Roebe::KdeKonsole
- Inherits:
-
Base
show all
- Defined in:
- lib/roebe/classes/kde/kde_konsole/help.rb,
lib/roebe/classes/kde/kde_konsole/run.rb,
lib/roebe/classes/kde/kde_konsole/menu.rb,
lib/roebe/classes/kde/kde_konsole/misc.rb,
lib/roebe/classes/kde/kde_konsole/reset.rb,
lib/roebe/classes/kde/kde_konsole/constants.rb,
lib/roebe/classes/kde/kde_konsole/initialize.rb,
lib/roebe/classes/kde/kde_konsole/kde_konsole.rb
Overview
Constant Summary
collapse
- DEFAULT_TITLE =
#
DEFAULT_TITLE
Designate which title we will use by default.
#
'.'
- ARRAY_ALL_ICONS =
#
ARRAY_ALL_ICONS
All icons should be registered here.
#
%w(
--weather-snow
--weather-snow-rain
--emblem-important
--emblem-mounted
--emblem-warning
--mail-mark-important
--document-import
--view-certificate-import
--folder-important
--media-optical-audio
--audio-input-microphone
--audio-x-generic
--audio-headphones
--face-angel
--face-embarrassed
--face-kiss
--face-laugh
--face-plain
--face-raspberry
--face-sad
--face-smile-big
--face-smile
--face-surprise
--face-uncertain
--face-wink
)
Constants inherited
from Base
Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE
Class Method Summary
collapse
-
.[](title = '') ⇒ Object
# === Roebe::KdeKonsole[] ========================================================================= #.
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, #copy_file, #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, #opnn, #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, #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_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(commandline_arguments = nil, run_already = true) ⇒ KdeKonsole
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/roebe/classes/kde/kde_konsole/initialize.rb', line 14
def initialize(
commandline_arguments = nil,
run_already = true
)
reset
set_commandline_arguments(
commandline_arguments
)
if block_given?
yielded = yield
case yielded
when :be_quiet,
:be_silent
@be_verbose = false
end
end
case run_already
when :do_not_run_yet
run_already = false
end
run if run_already
end
|
Class Method Details
.[](title = '') ⇒ Object
192
193
194
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 192
def self.[](title = '')
new(title)
end
|
Instance Method Details
#clear_kde_konsole_tab_icon ⇒ Object
#
clear_kde_konsole_tab_icon
#
178
179
180
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 178
def clear_kde_konsole_tab_icon
e "\e]32;\a"
end
|
#commandline_arguments? ⇒ Boolean
#
commandline_arguments?
#
108
109
110
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 108
def commandline_arguments?
@commandline_arguments
end
|
#do_not_change_the_title ⇒ Object
Also known as:
do_not_rename_tab
#
do_not_change_the_title
#
81
82
83
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 81
def do_not_change_the_title
@internal_hash[:make_use_of_the_title] = false
end
|
#do_use_unicode ⇒ Object
185
186
187
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 185
def do_use_unicode
ENV['LC_ALL'] = 'en_US.utf8'
end
|
#ensure_that_a_proper_title_is_set ⇒ Object
#
ensure_that_a_proper_title_is_set
#
88
89
90
91
92
93
94
95
96
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 88
def ensure_that_a_proper_title_is_set
unless title?
if commandline_arguments?.empty?
set_title(:default_title)
else
set_title(joined_commandline_arguments)
end
end
end
|
#important_notification ⇒ Object
#
important_notification
#
199
200
201
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 199
def important_notification
use_this_icon('emblem-important')
end
|
#joined_commandline_arguments ⇒ Object
#
joined_commandline_arguments
#
101
102
103
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 101
def joined_commandline_arguments
commandline_arguments?.join(' ').strip
end
|
#make_use_of_the_title? ⇒ Boolean
#
make_use_of_the_title?
#
74
75
76
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 74
def make_use_of_the_title?
@internal_hash[:make_use_of_the_title]
end
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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
|
# File 'lib/roebe/classes/kde/kde_konsole/menu.rb', line 14
def (
i = @commandline_arguments
)
if i.is_a? Array
i.each {|entry| (entry) }
else
if i.to_s.encoding.to_s == 'US-ASCII'
i = ensure_main_encoding(i.to_s)
end
case i when /^-?-?absolute$/i
set_title(
return_pwd
)
when /^-?-?short(-|_)?pwd$/i,
/^-?-?short(-|_)?path$/i,
/^-?-?short$/i,
/^-?-?only(-|_)?last$/i
set_title(
return_last_part_of_the_current_directory )
when /^-?-?weather(-|_)?snow$/i, /^-?-?weather(-|_)?snow(-|_)?rain$/i, /^-?-?emblem(-|_)?important$/i, /^-?-?emblem(-|_)?mounted$/i, /^-?-?emblem(-|_)?warning$/i, /^-?-?important$/i, /^-?-?mounted$/i, /^-?-?warning$/i, /^-?-?mail(-|_)?mark(-|_)?important$/i, /^-?-?document(-|_)?import$/i, /^-?-?view(-|_)?certificate(-|_)?import$/i, /^-?-?folder(-|_)?important$/i, /^-?-?media(-|_)?optical(-|_)?audio$/i, /^-?-?audio(-|_)?input(-|_)?microphone$/i, /^-?-?audio(-|_)?x(-|_)?generic$/i, /^-?-?audio(-|_)?headphones$/i, /^-?-?headphones$/i, /^-?-?utilities(-|_)?terminal$/i, /^-?-?terminal$/i use_this_icon(i) do_not_change_the_title
when /^-?-?no(-|_)?icon$/i,
/^-?-?clear(-|_)?icons?$/i
clear_kde_konsole_tab_icon
do_not_change_the_title
when /^-?-?dialog(-|_)warning$/i
set_title(
use_this_icon(i)
)
when /^-?-?snowman$/i
set_title(Roebe.snowman)
when /^-?-?image=(.+)$/i, /^-?-?use(-|_)?this(-|_)?image=(.+)$/i match = $1.to_s.dup
match = $3.to_s.dup if $3
use_this_icon(match)
do_not_change_the_title
when /^-?-?kde(-|_)?icon(\d+)$/i
_ = $2.to_s.dup.to_i
use_this_icon(
ARRAY_ALL_ICONS[_ - 1]
)
do_not_change_the_title
when /^-?-?random(-|_)?icon$/i
_ = ARRAY_ALL_ICONS.sample
use_this_icon(_)
do_not_change_the_title
when /^-?-?face(-|_)angel$/i, /^-?-?face(-|_)embarrassed$/i, /^-?-?face(-|_)kiss$/i, /^-?-?face(-|_)laugh$/i, /^-?-?face(-|_)plain$/i, /^-?-?face(-|_)raspberry$/i, /^-?-?face(-|_)sad$/i, /^-?-?face(-|_)smile(-|_)big$/i, /^-?-?face(-|_)smile$/i, /^-?-?face(-|_)surprise$/i, /^-?-?face(-|_)uncertain$/i, /^-?-?face(-|_)wink$/i use_this_icon(i)
do_not_change_the_title
when /^-?-?return(-|_)important(-|_)notification$/i
set_title(
return_this_icon('folder-important')
)
when /^-?-?important(-|_)notification$/i
set_title(
use_this_icon('folder-important')
)
when /^-?-?warning$/i
use_this_icon(i)
when /^-?-?waiting$/i
use_this_icon(i)
when /^-?-?help$/
show_help
exit
when /^-?-?verbose$/,
/^-?-?be( |_|-)?verbose$/
set_be_verbose
else if i and File.exist?(i) and File.file?(i)
do_not_rename_tab
use_this_icon(i)
end
end
end
end
|
#rename_konsole_title(be_verbose = be_verbose?,
, use_which_mode = :non_qdbus_mode) ⇒ Object
#
rename_konsole_title
This is the main workhorse method for this class.
The (optional) argument tells us whether we will be verbose or whether we will be not verbose.
There are at the least two ways how to change the title of a KDE konsole tab:
(1) Make use of "qdbus".
(2) Make use of echo -ne.
#
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 34
def rename_konsole_title(
be_verbose = be_verbose?,
use_which_mode = :non_qdbus_mode
)
text_to_show = input?
if try_to_replace_ascii_arrows? and
(
text_to_show.include?('<-') or text_to_show.include?('->')
)
text_to_show.gsub!(/\<-/, '←')
text_to_show.gsub!(/-\>/, '→')
end
case use_which_mode
when :default, :non_qdbus_mode
_ = "\e]30;#{text_to_show}\a"
e _
when :qdbus_mode
_ = 'qdbus org.kde.konsole $KONSOLE_DBUS_SESSION setTitle 1 "'+text_to_show+'"'
e _ if be_verbose
system _
end
end
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/roebe/classes/kde/kde_konsole/reset.rb', line 14
def reset
super()
infer_the_namespace
@title = nil
@be_verbose = true @internal_hash = {}
@internal_hash[:make_use_of_the_title] = true
@internal_hash[:try_to_replace_ascii_arrows] = true
end
|
#return_important_notification ⇒ Object
Also known as:
important
#
return_important_notification
Do note that “important” is an alias to this method which could change at some later moment in time. I needed to have this as the “main” alias so that I can use it from other projects.
#
210
211
212
213
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 210
def return_important_notification
return_this_icon('emblem-important')
end
|
#return_this_icon(i) ⇒ Object
#
return_this_icon
This method is useful to return the String for a specific icon that can be shown in a KDE konsole tab (on the left side of it).
#
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
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 240
def return_this_icon(i)
i = i.dup
case i when /^-?-?warning$/i
i = 'emblem-warning'
when /^-?-?mounted$/i
i = 'emblem-mounted'
when /^-?-?important$/i
i = 'emblem-important'
when /^-?-?terminal$/i
i = 'utilities-terminal'
when /^-?-?headphones$/i
i = 'audio-headphones'
end
if i.start_with? '--'
i[0,2] = ''
end
"\033]32;#{i}\007"
end
|
14
15
16
17
18
19
20
|
# File 'lib/roebe/classes/kde/kde_konsole/run.rb', line 14
def run
if make_use_of_the_title?
ensure_that_a_proper_title_is_set
rename_konsole_title
end
end
|
#set_title(i = DEFAULT_TITLE) ⇒ Object
Also known as:
set_use_this_as_title, set_input
#
set_title
This method can be used to set the title that we wish to use for the current KDE konsole tab.
Note that input such as :snowman, will be assumed to be for the Unicode snowman.
For a good overview of nice unicode symbols, have a look at:
http://jrgraphix.net/r/Unicode/2600-26FF
#
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
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 133
def set_title(i = DEFAULT_TITLE)
i = i.join(' ').strip if i.is_a? Array
case i
when :default, :default_title, nil
i = DEFAULT_TITLE
end
i = DEFAULT_TITLE if i.empty?
if i.is_a? Symbol
i = ":#{i}" end
i = i.to_s.dup
if i.start_with? ':'
i = ::Roebe.map_input_to_unicode_symbol(i)
end
case i when /^LAST_?NAME_?ONLY/
if return_pwd.include? HOME_OF_THE_USER_CALLED_X
i = return_last_part_of_the_current_directory
end
when /^PWD_?LAST/,
/^-?-?short(-|_)?pwd$/i
i = return_last_part_of_the_current_directory when 'PWD'
i = return_current_directory
end
@title = i
end
|
#show_help ⇒ Object
#
show_help (help tag)
To invoke this from the commandline, try:
rti --help
#
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/roebe/classes/kde/kde_konsole/help.rb', line 19
def show_help
help_string = <<-EOF
#{grey}The following options are documented/available for #{sfancy('class Roebe::KdeKonsole')}#{grey}:
--be-verbose # show the command that is to be used
--random-icon # use a random icon for a KDE Konsole tab
--absolute # use the absolute path (aka "pwd") for the current working directory
EOF
e help_string
end
|
#title? ⇒ Boolean
Also known as:
input?
115
116
117
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 115
def title?
@title
end
|
#try_to_replace_ascii_arrows? ⇒ Boolean
#
try_to_replace_ascii_arrows?
#
15
16
17
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 15
def try_to_replace_ascii_arrows?
@internal_hash[:try_to_replace_ascii_arrows]
end
|
#use_terminal_icon ⇒ Object
218
219
220
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 218
def use_terminal_icon
use_this_icon('--terminal')
end
|
#use_this_icon(i) ⇒ Object
#
use_this_icon
Note that this method here will instantly “display” the result, aka apply this icon onto the commandline. If you only need to return the String for it, use the method called return_this_icon().
#
229
230
231
232
|
# File 'lib/roebe/classes/kde/kde_konsole/misc.rb', line 229
def use_this_icon(i)
use_this_path = return_this_icon(i)
e use_this_path
end
|