File: segment-plugin.go

package info (click to toggle)
powerline-go 1.25-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 612 kB
  • sloc: sh: 30; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 496 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package main

import (
	"encoding/json"
	"os/exec"

	pwl "github.com/justjanne/powerline-go/powerline"
)

func segmentPlugin(p *powerline, plugin string) ([]pwl.Segment, bool) {
	output, err := exec.Command("powerline-go-" + plugin).Output()
	if err != nil {
		return nil, false
	}
	segments := []pwl.Segment{}
	err = json.Unmarshal(output, &segments)
	if err != nil {
		// The plugin was found but no valid data was returned. Ignore it
		return []pwl.Segment{}, true
	}
	return segments, true
}