github.com/metux/go-metabuild@v0.0.0-20240118143255-d9ed5ab697f9/engine/builder/data/desktop.go (about)

     1  package data
     2  
     3  import (
     4  	"github.com/metux/go-metabuild/engine/builder/base"
     5  	"github.com/metux/go-metabuild/spec"
     6  	"github.com/metux/go-metabuild/spec/target"
     7  	"github.com/metux/go-metabuild/util"
     8  	"github.com/metux/go-metabuild/util/fileutil"
     9  )
    10  
    11  type BuilderDataDesktop struct {
    12  	base.BaseBuilder
    13  }
    14  
    15  func (b BuilderDataDesktop) JobRun() error {
    16  	text := []string{
    17  		"[Desktop Entry]",
    18  		"Version=1.1",
    19  		"Type=" + b.RequiredEntryStr(target.KeyDesktopType),
    20  		"Name=" + b.RequiredEntryStr(target.KeyDesktopName),
    21  		"GenericName=" + b.EntryStr(target.KeyDesktopGenericName),
    22  		"Comment=" + util.StrEscLF(b.EntryStr(target.KeyDesktopComment)),
    23  		"Icon=" + b.EntryStr(target.KeyDesktopIconFile),
    24  		"Exec=" + b.EntryStr(target.KeyDesktopExec),
    25  		"TryExec=" + b.EntryStr(target.KeyDesktopTryExec),
    26  		"Terminal=" + b.EntryStr(target.KeyDesktopTerminal),
    27  		"Categories=" + b.EntryStr(target.KeyDesktopCategories)}
    28  
    29  	if err := fileutil.WriteFileLines(b.OutputFile(), text); err != nil {
    30  		return err
    31  	}
    32  
    33  	b.InstallPkgFileAuto()
    34  	return nil
    35  }
    36  
    37  func (b BuilderDataDesktop) JobPrepare(id string) error {
    38  	return nil
    39  }
    40  
    41  func MakeDataDesktop(o spec.TargetObject, id string) BuilderDataDesktop {
    42  	return BuilderDataDesktop{base.BaseBuilder{o, id}}
    43  }