6 changed files with 348 additions and 44 deletions
@ -0,0 +1,127 @@
|
||||
# |
||||
# Configuration file for tut |
||||
|
||||
[general] |
||||
# If the program should check for new toots without user interaction. |
||||
# If you don't enable this the program will only look for new toots when |
||||
# you reach the bottom or top of your feed. With this enabled it will check |
||||
# for new toots every x second. |
||||
# default=true |
||||
auto-load-newer=true |
||||
|
||||
# How many seconds between each pulling of new toots if you have enabled |
||||
# auto-load-newer. |
||||
# default=60 |
||||
auto-load-seconds=60 |
||||
|
||||
|
||||
# The date format to be used |
||||
# See https://godoc.org/time#Time.Format |
||||
# default=2006-01-02 15:04 |
||||
date-format=2006-01-02 15:04 |
||||
|
||||
# Format for dates the same day |
||||
# default=15:04 |
||||
date-today-format=15:04 |
||||
|
||||
# The timeline that opens up when you start tut |
||||
# Valid values: home, direct, local, federated |
||||
# default=home |
||||
timeline=home |
||||
|
||||
[media] |
||||
# Your image viewer |
||||
# default=xdg-open |
||||
image-viewer=xdg-open |
||||
|
||||
# If image should open one by one e.g. "imv image.png" multiple times |
||||
# If set to false all images will open at the same time like this |
||||
# "imv image1.png image2.png image3.png". |
||||
# Not all image viewers support this, so try it first. |
||||
# default=true |
||||
image-single=true |
||||
|
||||
# Your video viewer |
||||
# default=xdg-open |
||||
video-viewer=xdg-open |
||||
|
||||
# If videos should open one by one. See above comment about image-single |
||||
# default=true |
||||
video-single=true |
||||
|
||||
# Your audio viewer |
||||
# default=xdg-open |
||||
audio-viewer=xdg-open |
||||
|
||||
# If audio files should open one by one. See above comment about image-single |
||||
# default=true |
||||
audio-single=true |
||||
|
||||
# Your web browser |
||||
# default=xdg-open |
||||
link-viewer=xdg-open |
||||
|
||||
[style] |
||||
# All styles can be represented in their HEX value like #ffffff or |
||||
# with their name, so in this case white. |
||||
# The only special value is "default" which equals to transparent, |
||||
# so it will be the same color as your terminal. But this can lead |
||||
# to some artifacts left from a previous paint |
||||
|
||||
# You can also use xrdb colors like this xrdb:color1 |
||||
# The program will use colors prefixed with an * first then look |
||||
# for URxvt or XTerm if it can't find any color prefixed with an asterix. |
||||
# If you don't want tut to guess the prefix you can set the prefix yourself. |
||||
# If the xrdb color can't be found a preset color will be used. |
||||
|
||||
# The xrdb prefix used for colors in .Xresources |
||||
# default=guess |
||||
xrdb-prefix=guess |
||||
|
||||
# The background color used on most elements |
||||
# default=xrdb:background |
||||
background=xrdb:background |
||||
|
||||
# The text color used on most of the text |
||||
# default=xrdb:foreground |
||||
text=xrdb:foreground |
||||
|
||||
# The color to display sublte elements or subtle text. Like lines and help text |
||||
# default=xrdb:color14 |
||||
subtle=xrdb:color14 |
||||
|
||||
# The color for errors or warnings |
||||
# default=xrdb:color1 |
||||
warning-text=xrdb:color1 |
||||
|
||||
# This color is used to display username |
||||
# default=xrdb:color5 |
||||
text-special-one=xrdb:color5 |
||||
|
||||
# This color is used to display username and keys |
||||
# default=xrdb:color2 |
||||
text-special-two=xrdb:color2 |
||||
|
||||
# The color of the bar at the top |
||||
# default=xrdb:color5 |
||||
top-bar-background=xrdb:color5 |
||||
|
||||
# The color of the text in the bar at the top |
||||
# default=xrdb:background |
||||
top-bar-text=xrdb:background |
||||
|
||||
# The color of the bar at the bottom |
||||
# default=xrdb:color0 |
||||
status-bar-background=xrdb:color0 |
||||
|
||||
# The color of the text in the bar at the bottom |
||||
# default=xrdb:foreground |
||||
status-bar-text=xrdb:foreground |
||||
|
||||
# Background of selected list items |
||||
# default=xrdb:color5 |
||||
list-selected-background=xrdb:color5 |
||||
|
||||
# The text color of selected list items |
||||
# default=xrdb:background |
||||
list-selected-text=xrdb:background |
||||
@ -0,0 +1,83 @@
|
||||
package main |
||||
|
||||
import ( |
||||
"os/exec" |
||||
"strconv" |
||||
"strings" |
||||
) |
||||
|
||||
type xrdbField struct { |
||||
Name string |
||||
Value string |
||||
} |
||||
|
||||
type XrdbColors map[string]map[string]string |
||||
|
||||
func getXrdb() ([]xrdbField, error) { |
||||
var xf []xrdbField |
||||
|
||||
out, err := exec.Command("xrdb", "-query").CombinedOutput() |
||||
if err != nil { |
||||
return xf, err |
||||
} |
||||
|
||||
lines := strings.Split(string(out), "\n") |
||||
for _, line := range lines { |
||||
parts := strings.Split(line, ":") |
||||
if len(parts) < 2 { |
||||
continue |
||||
} |
||||
|
||||
xf = append(xf, |
||||
xrdbField{ |
||||
Name: strings.TrimSpace(parts[0]), |
||||
Value: strings.TrimSpace( |
||||
strings.Join(parts[1:], ":"), |
||||
), |
||||
}, |
||||
) |
||||
} |
||||
|
||||
return xf, nil |
||||
} |
||||
|
||||
func GetXrdbColors() (XrdbColors, error) { |
||||
colors := make(XrdbColors) |
||||
|
||||
xf, err := getXrdb() |
||||
if err != nil { |
||||
return colors, err |
||||
} |
||||
|
||||
for _, field := range xf { |
||||
parts := strings.Split(field.Name, ".") |
||||
if len(parts) == 1 && strings.HasPrefix(parts[0], "*") { |
||||
parts = append(parts, parts[0][1:]) |
||||
parts[0] = "*" |
||||
} |
||||
if len(parts) != 2 { |
||||
continue |
||||
} |
||||
|
||||
c := parts[1] |
||||
if c != "background" && c != "foreground" && !strings.HasPrefix(c, "color") { |
||||
continue |
||||
} |
||||
|
||||
if strings.HasPrefix(c, "color") { |
||||
num := strings.TrimPrefix(c, "color") |
||||
i, err := strconv.Atoi(num) |
||||
|
||||
if err != nil || i < 0 || i > 15 { |
||||
continue |
||||
} |
||||
} |
||||
|
||||
if _, ok := colors[parts[0]]; !ok { |
||||
colors[parts[0]] = make(map[string]string) |
||||
} |
||||
colors[parts[0]][c] = field.Value |
||||
} |
||||
|
||||
return colors, nil |
||||
} |
||||
Loading…
Reference in new issue