splashrc 1.0 → 1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf7616fa64b7edb1d78501fb92f7c7722b131528
4
- data.tar.gz: a3d2c83609170bbde1b5c9be5dd00e966fce9c41
3
+ metadata.gz: dd806b933b3d5708d0425c244923e21a496fcbf1
4
+ data.tar.gz: cf42ef51713f4f4219775be740c01f2589a2ec05
5
5
  SHA512:
6
- metadata.gz: 954facfd62dfcb4f69fb2fe5da1699e84b200e2a8c0b64f11410203db555abf59630ff1ca143bf06e24ffb4cd96c052ecb672d3a10cb016a60199a7efdede07d
7
- data.tar.gz: adaee44fd4136e8b0670869e97593bea4c6ba3ac5e43722a0d80d11c0817342bca7adfbb97852fad0e06c3ca5bbd899710ed5cb0c6fff1e192b7c69a34a29dd3
6
+ metadata.gz: 494c32df9d307cce582d6cd71b2d77cb14215754a6f0bd92fe6a82dd90cf3ee7eaf89a0b91529f094bc49b57caddb8e60678579236df76e1222058ab68d190ec
7
+ data.tar.gz: 1ed26c929ec347871480f3725f0f422273e6b2362659e1ddb07ac3841b6cacecc94d08d1c6bc5b57e78ae630cd6523e72a71d27f7bb0d6c5d9869b5afa77f8bb
data/bin/splashrc ADDED
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/ruby
2
+ require 'socket' # for Socket.gethostname()
3
+ require 'rbconfig'
4
+ require 'open3'
5
+ #deps: xorg-xrandr
6
+
7
+
8
+ $rc = %Q(\
9
+ -/+:.|||||||||||
10
+ :++++.|||||||||||
11
+ /+++/|||||||||||||
12
+ .:-::- .+/:-``.::-||||||||
13
+ .:/++++++/::::/++++++/:`||||
14
+ .:///////////////////////:`|||
15
+ ////////////////////////`|||||
16
+ -+++++++++++++++++++++++`||||||
17
+ /++++++++++++++++++++++/|||||||
18
+ /sssssssssssssssssssssss.||||||
19
+ :ssssssssssssssssssssssss-|||||
20
+ osssssssssssssssssssssssso/`||
21
+ `syyyyyyyyyyyyyyyyyyyyyyyy+`||
22
+ `ossssssssssssssssssssss/||||
23
+ :ooooooooooooooooooo+.|||||
24
+ `:+oo+/:-..-:/+o+/-|||||||
25
+ ).split("\n")
26
+
27
+
28
+ colors = [
29
+ "\e[1;32m%s\e[0;39m",
30
+ "\e[1;32m%s\e[0;39m",
31
+ "\e[1;32m%s\e[0;39m",
32
+ "\e[1;32m%s\e[0;39m",
33
+ "\e[1;32m%s\e[0;39m",
34
+ "\e[1;33m%s\e[0;39m",
35
+ "\e[1;33m%s\e[0;39m",
36
+ "\e[1;31m%s\e[0;39m",
37
+ "\e[1;31m%s\e[0;39m",
38
+ "\e[0;31m%s\e[0;39m",
39
+ "\e[0;31m%s\e[0;39m",
40
+ "\e[0;35m%s\e[0;39m",
41
+ "\e[0;35m%s\e[0;39m",
42
+ "\e[0;34m%s\e[0;39m",
43
+ "\e[0;34m%s\e[0;39m",
44
+ "\e[0;34m%s\e[0;39m",
45
+ ]
46
+
47
+ uptime=`uptime`.split("user")[0].split("up")[-1].split(",")[0].split(/\s+/)[1].gsub(" days", "d").gsub(" min","m").gsub(":","h ")
48
+ uptime.match(/^\d+h\s+\d+$/)&&uptime="0d #{uptime}m"
49
+ uptime.match(/^\d+m$/)&&uptime="0d 0h #{uptime}"
50
+
51
+ res = Open3.capture3("xrandr")
52
+ if res[-1].to_s.split[-1].to_i!=0
53
+ require 'io/console'
54
+ res = IO.console.winsize.join("x")+"(chrs)"
55
+ else
56
+ res[0,1].join.split("\n").select!{|i|i.match(/^Screen #{ENV['DISPLAY'].reverse}/)}
57
+ res = res[0].split(/,\s+/).select!{|i|i.match(/current\s*\d+\s*x\s*\d+\s*/)}[0]
58
+ res = res.split.drop(1).join+"(px)"
59
+ end
60
+
61
+ irb_loc = (`which irb`.match(/^which:/).nil? ? `which irb`.chomp : "*r*NOT FOUND")
62
+ cpu_name= File.read("/proc/cpuinfo").split("\n").select{|i|i.match(/^model\s+name\s+:\s+.+/)}[0].split(/\s*:\s*/)[-1]
63
+ ram_info=`free -m`.split("\n")[1].split[1,2].reverse.join("MiB / ")+"MiB"
64
+
65
+ add = [
66
+ "#{ENV["USER"]}*w*@*c*#{Socket.gethostname}",
67
+ "OS:*w* #{RbConfig::CONFIG['host_os'].upcase}",
68
+ "Kernel:*w* #{`uname -r`.chomp}",
69
+ "Uptime:*w* #{uptime}",
70
+ "Locale:*w* #{ENV['LANG']}",
71
+ "Time:*w* #{Time.now}",
72
+ "Timezone:*w* #{Time.new.zone}",
73
+ "Ruby:*w* #{ENV['_']}",
74
+ "Ruby version:*w* #{RUBY_VERSION}",
75
+ "Gems:*w* #{`gem list`.split("\n").length}",
76
+ "Shell:*w* #{ENV['SHELL']}",
77
+ "IRB:*w* #{irb_loc}",
78
+ "Resolution:*w* #{res}",
79
+ "CPU:*w* #{cpu_name}",
80
+ "RAM:*w* #{ram_info}",
81
+ "",
82
+ ]
83
+
84
+ $rc.each_with_index{ |i,ind| $rc[ind] = colors[ind].gsub("%s",$rc[ind]).gsub("|"," ").concat("\e[1;36m").concat(add[ind]).concat("\e[39m").gsub("*w*","\e[37m").gsub("*c*","\e[1;36m").gsub("*r*","\e[0;31m") }
85
+ at_exit{puts "\e[0;39m"}
86
+
87
+ puts
88
+ puts $rc
89
+ puts
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby
2
+
3
+ loc = ARGV.shift
4
+ if loc.nil?
5
+ loc = "#{ENV["SHELL"].split("/")[-1]}"
6
+ loc.gsub!(/^sh/,"bash")
7
+ loc = "#{File.expand_path("~")}/.#{loc}rc"
8
+ end
9
+
10
+ File.exists?(loc)||(puts("#{loc} does not exist.");exit(1))
11
+
12
+ print "Deinstall rbrc for `#{loc}`? [Y/n]"
13
+ c = gets.chomp
14
+
15
+ if ["y",""].include? c.downcase
16
+ x = File.read(loc).split("\n")
17
+ x.delete_at(x.index(x.select{|i|i.match(/^rbrc/)}[0]))
18
+ x = x.join("\n")
19
+ File.write(loc,x)
20
+ puts "Success!"
21
+ end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby
2
+
3
+ loc = ARGV.shift
4
+ if loc.nil?
5
+ loc = "#{ENV["SHELL"].split("/")[-1]}"
6
+ loc.gsub!(/^sh/,"bash")
7
+ loc = "#{File.expand_path("~")}/.#{loc}rc"
8
+ end
9
+
10
+ File.exists?(loc)||(puts("#{loc} does not exist.");exit(1))
11
+
12
+ print "Install rbrc for `#{loc}`? [Y/n]"
13
+ c = gets.chomp
14
+
15
+ if ["y",""].include? c.downcase
16
+ x = File.read(loc).split("\n")
17
+ x << %Q(rbrc # THIS ALWAYS HAS TO BE THE LAST LINE)
18
+ x = x.join("\n")
19
+ File.write(loc,x)
20
+ puts "Success!"
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splashrc
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - sesshomariu
@@ -13,10 +13,16 @@ dependencies: []
13
13
  description: Creates a splash screen with some system information and an oldschool
14
14
  iMac logo when starting a bash
15
15
  email:
16
- executables: []
16
+ executables:
17
+ - splashrc
18
+ - splashrc-enable
19
+ - splashrc-disable
17
20
  extensions: []
18
21
  extra_rdoc_files: []
19
- files: []
22
+ files:
23
+ - bin/splashrc
24
+ - bin/splashrc-disable
25
+ - bin/splashrc-enable
20
26
  homepage:
21
27
  licenses: []
22
28
  metadata: {}