-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
285 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pre-commit: | ||
commands: | ||
gofmt: | ||
run: | | ||
set -e | ||
for file in $(git diff --cached --name-only --diff-filter=ACM | grep '\.go$'); do | ||
gofmt -w "$file" | ||
git add "$file" | ||
done | ||
glob: "*.go" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,68 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
"os" | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
"os" | ||
) | ||
|
||
|
||
var applyCmd = &cobra.Command{ | ||
Use: "apply [path]", | ||
Short: "Apply changes from a profile.json", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := applyProfile(args[0]) | ||
if err != nil { | ||
fmt.Printf("Error: %s\n", err) | ||
} | ||
}, | ||
Use: "apply [path]", | ||
Short: "Apply changes from a profile.json", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := applyProfile(args[0]) | ||
if err != nil { | ||
fmt.Printf("Error: %s\n", err) | ||
} | ||
}, | ||
} | ||
|
||
var revertCmd = &cobra.Command{ | ||
Use: "revert [path]", | ||
Short: "Revert changes from a profile.json", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := revertProfile(args[0]) | ||
if err != nil { | ||
fmt.Printf("Error: %s\n", err) | ||
} | ||
}, | ||
Use: "revert [path]", | ||
Short: "Revert changes from a profile.json", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := revertProfile(args[0]) | ||
if err != nil { | ||
fmt.Printf("Error: %s\n", err) | ||
} | ||
}, | ||
} | ||
|
||
var recordCmd = &cobra.Command{ | ||
Use: "record", | ||
Short: "Record changes to xsettings and dump them as a profile on SIGINT", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
recordProfile() | ||
}, | ||
Use: "record", | ||
Short: "Record changes to xsettings and dump them as a profile on SIGINT", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
recordProfile() | ||
}, | ||
} | ||
|
||
var syncCmd = &cobra.Command{ | ||
Use: "sync", | ||
Short: "Sync user profile with distribution's recommended profile", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
distProfile, _ := cmd.Flags().GetString("profile") | ||
if err := syncProfile(distProfile); err != nil { | ||
fmt.Fprintf(os.Stderr, "Error: %v\n", err) | ||
os.Exit(1) | ||
} | ||
}, | ||
Use: "sync", | ||
Short: "Sync user profile with distribution's recommended profile", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
distProfile, _ := cmd.Flags().GetString("profile") | ||
if err := syncProfile(distProfile); err != nil { | ||
fmt.Fprintf(os.Stderr, "Error: %v\n", err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
syncCmd.Flags().StringP("profile", "p", "/usr/share/xfconf-profile/default.json", "Path to the distribution's recommended profile") | ||
} | ||
|
||
func main() { | ||
var rootCmd = &cobra.Command{ | ||
Use: "xfconf-profile", | ||
Short: "Tool for applying, reverting and managing Xfce profiles", | ||
} | ||
rootCmd.AddCommand(applyCmd, revertCmd, recordCmd, syncCmd) | ||
var rootCmd = &cobra.Command{ | ||
Use: "xfconf-profile", | ||
Short: "Tool for applying, reverting and managing Xfce profiles", | ||
} | ||
rootCmd.AddCommand(applyCmd, revertCmd, recordCmd, syncCmd) | ||
|
||
if err := rootCmd.Execute(); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
if err := rootCmd.Execute(); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.