1 #!/usr/bin/env python2.7
9 pattern
= re
.compile(current_file_name
)
11 for i
, line
in enumerate(open(tint2_config_path
, 'r')):
12 for match
in re
.finditer(pattern
, line
):
13 # print 'Found on line %s: %s' % (i+1, match.groups())
17 def get_line_data(file_name
, line
):
18 """Open file go to line and return data."""
19 line
= linecache
.getline(file_name
, line
)
23 def find_color_from_string(the_string
):
24 """Search in a string for a patter #.*."""
25 p
= re
.compile("(#.{6})")
26 result
= p
.search(the_string
)
27 return result
.group(1)
32 ram_color
= find_color_from_string(
34 file_name
=tint2_config_path
, line
=color_line
))
38 elif ram_color
== default_color
:
39 result
= "default_color"
45 def change_to_color(color
):
46 with
open(tint2_config_path
, 'r') as file:
47 lines
= file.readlines()
49 the_new_line
= "execp_font_color = " + color
+ " 100"
50 lines
[color_line
-1] = the_new_line
+ "\n"
52 with
open(tint2_config_path
, 'w') as file:
53 file.writelines(lines
)
56 current_file_name
= os
.path
.basename(__file__
)
57 restart
= "killall -SIGUSR1 tint2"
59 default_color
= "#d8d8d8"
61 tint2_config_path
= "/home/hassan/Dropbox/development/linux_conf/openbox/tint2/test_color/tint2rc"
62 color_line
= (find_the_line()+13)
65 change_to_color(default_color
)
70 # if get_color() == default_color:
72 # elif get_ram_color() == red: