xres2tlx 0.1.0
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 +7 -0
- data/.standard.yml +3 -0
- data/Gemfile +10 -0
- data/README.md +26 -0
- data/Rakefile +14 -0
- data/bin/xres2tlx +3 -0
- data/lib/xres2tlx/converter.rb +70 -0
- data/lib/xres2tlx/version.rb +5 -0
- data/lib/xres2tlx.rb +22 -0
- data/sig/xres2tlx.rbs +4 -0
- metadata +57 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d0d48e4b5d808590cb77164ceb4ab458f1429cd9ecd6b355aa8ec0e79fc7b4b4
|
4
|
+
data.tar.gz: b6d80cc139aa98cf591c90af1506b0445190a5026e8cc52e17ce109c8a4826bb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a27832dc94816018784844a58ce33b1420dfadebdc29c9c21e44784811181bad4ee7ebebbeab8995f98a0a21db85748d31553d8808310a5caf7b0a3538df8dc9
|
7
|
+
data.tar.gz: 7660a2fe91fa848afa6e47466e58f1d1d0a578a3bec9c2ab9881a4f9a62355600fede98fdac79ff7fdd79231161dd04dc6a95c6f0fc976197027e434ac92ba5c
|
data/.standard.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# xres2tlx
|
2
|
+
Convert colorschemes in Xresource files to Tilix JSON colorschemes.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
```sh
|
6
|
+
$ xres2tlx <path-to-xresources-file> > colorscheme.json
|
7
|
+
```
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
__From https://rubygems.org__
|
11
|
+
```
|
12
|
+
gem install xres2tlx
|
13
|
+
```
|
14
|
+
|
15
|
+
__From source__
|
16
|
+
##### One-liner
|
17
|
+
```
|
18
|
+
# Coming soon
|
19
|
+
```
|
20
|
+
##### Manual
|
21
|
+
```
|
22
|
+
# Coming soon
|
23
|
+
```
|
24
|
+
|
25
|
+
## License
|
26
|
+
xres2tlx is licensed under the MIT license. For more information, please see the (LICENSE)[https://github.com/pinecat/xres2tlx/blob/master/LICENSE].
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "standard/rake"
|
5
|
+
|
6
|
+
path = File.dirname(__FILE__)
|
7
|
+
bin = File.expand_path(path) + "/bin/xres2tlx"
|
8
|
+
lib = File.expand_path(path) + "/lib"
|
9
|
+
|
10
|
+
task default: :standard
|
11
|
+
|
12
|
+
task :run, [:filepath] do |t, args|
|
13
|
+
sh "ruby -I#{lib} #{bin} #{args[:filepath]}"
|
14
|
+
end
|
data/bin/xres2tlx
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
class Converter
|
6
|
+
def initialize(filepath)
|
7
|
+
# Check if the file exists
|
8
|
+
unless File.exist?(filepath)
|
9
|
+
warn "xres2tlx: Could not find the file: #{filepath}, quitting..."
|
10
|
+
exit 1
|
11
|
+
end
|
12
|
+
|
13
|
+
# Set the xres_filepath
|
14
|
+
@xres_filepath = filepath
|
15
|
+
@unordered_pref = {palette: []}
|
16
|
+
@tlx_pref = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def read_xres_file
|
20
|
+
# Read the file
|
21
|
+
text = File.read(@xres_filepath)
|
22
|
+
|
23
|
+
# Split text by line, and iterate over each line
|
24
|
+
text.split("\n").each do |line|
|
25
|
+
# Only set values if line does not begin with the comment character ('!')
|
26
|
+
unless line[0] == "!"
|
27
|
+
# Get the hex value
|
28
|
+
color = line.split(":").last.strip.upcase.chomp
|
29
|
+
|
30
|
+
# Set preferences
|
31
|
+
@unordered_pref["background-color"] = color if line.include? "background" # Background color
|
32
|
+
@unordered_pref["foreground-color"] = color if line.include? "foreground" # Foreground color
|
33
|
+
@unordered_pref["cursor-background-color"] = color if line.include? "cursorColor" # Cursor color
|
34
|
+
@unordered_pref["cursor-foreground-color"] = color if line.include? "cursorColor" # Cursor color
|
35
|
+
@unordered_pref["bold-color"] = color if line.include? "colorBD" # Bold color
|
36
|
+
|
37
|
+
# Palette
|
38
|
+
# Only set palette if line just includes "color", NOT "colorBD"
|
39
|
+
unless line.include? "colorBD"
|
40
|
+
@unordered_pref[:palette].push(color) if line.include? "color"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def set_tlx_pref
|
47
|
+
@tlx_pref = {
|
48
|
+
"background-color": @unordered_pref["background-color"],
|
49
|
+
"badge-color": "#FFFFFF",
|
50
|
+
"bold-color": @unordered_pref["bold-color"],
|
51
|
+
comment: "This colorscheme was generated using xres2tlx.",
|
52
|
+
"cursor-background-color": @unordered_pref["cursor-background-color"],
|
53
|
+
"cursor-foreground-color": @unordered_pref["cursor-foreground-color"],
|
54
|
+
"foreground-color": @unordered_pref["foreground-color"],
|
55
|
+
"highlight-background-color": "#000000",
|
56
|
+
"highlight-foreground-color": "#FFFFFF",
|
57
|
+
name: @xres_filepath.split("/").last.strip.chomp,
|
58
|
+
palette: @unordered_pref[:palette],
|
59
|
+
"use-badge-color": false,
|
60
|
+
"use-bold-color": true,
|
61
|
+
"use-cursor-color": true,
|
62
|
+
"use-highlight-color": false,
|
63
|
+
"use-theme-colors": false
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
def output_tlx_file
|
68
|
+
puts JSON.pretty_generate(@tlx_pref)
|
69
|
+
end
|
70
|
+
end
|
data/lib/xres2tlx.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "xres2tlx/converter"
|
4
|
+
require_relative "xres2tlx/version"
|
5
|
+
|
6
|
+
module Xres2tlx
|
7
|
+
class Error < StandardError; end
|
8
|
+
|
9
|
+
def self.init(args)
|
10
|
+
# Check the args
|
11
|
+
if args.length == 0 || args.length > 1
|
12
|
+
warn "Usage: xres2tlx <path-to-xresources-file>"
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
|
16
|
+
# Create the converter, and do the conversion
|
17
|
+
conv = Converter.new(args[0])
|
18
|
+
conv.read_xres_file
|
19
|
+
conv.set_tlx_pref
|
20
|
+
conv.output_tlx_file
|
21
|
+
end
|
22
|
+
end
|
data/sig/xres2tlx.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xres2tlx
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rory Dudley
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-04-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Convert Xresource colorschemes into Tilix colorschemes (mostly meant
|
14
|
+
to be used with the Xresource files at https://github.com/mbadolato/iTerm2-Color-Schemes).
|
15
|
+
email:
|
16
|
+
- rory.dudley@gmail.com
|
17
|
+
executables:
|
18
|
+
- xres2tlx
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- ".standard.yml"
|
23
|
+
- Gemfile
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- bin/xres2tlx
|
27
|
+
- lib/xres2tlx.rb
|
28
|
+
- lib/xres2tlx/converter.rb
|
29
|
+
- lib/xres2tlx/version.rb
|
30
|
+
- sig/xres2tlx.rbs
|
31
|
+
homepage: https://github.com/pinecat/xres2tlx
|
32
|
+
licenses:
|
33
|
+
- MIT
|
34
|
+
metadata:
|
35
|
+
allowed_push_host: https://rubygems.org
|
36
|
+
homepage_uri: https://github.com/pinecat/xres2tlx
|
37
|
+
source_code_uri: https://github.com/pinecat/xres2tlx
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.6.0
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubygems_version: 3.3.7
|
54
|
+
signing_key:
|
55
|
+
specification_version: 4
|
56
|
+
summary: Xresources to Tilix
|
57
|
+
test_files: []
|