This commit is contained in:
bruno 2023-07-26 16:11:47 -04:00
parent c80099524e
commit e74f1da2af
9 changed files with 82 additions and 23 deletions

View File

@ -5,9 +5,13 @@ Scut-Reminder est un petit utilitaire en ligne de commande pour gérer et lister
## Usage ## Usage
``` ```
scut // Affiche la liste des applications scut // Affiche la liste des applications
scut -c MaConfig.json -a "nevim" // Affiche liste des raccourcis de nevim de MaConfig.json
scut -a "Visual Studio Code" // Affiche liste des raccourcis de vscode scut -c MaConfig.json -a "nevim" // Affiche liste des raccourcis de nevim de MaConfig.json
scut -a "Visual Studio Code" // Affiche liste des raccourcis de vscode
scut -u // Afficher liste des urls d'aide au raccourcis
``` ```
## Options ## Options

View File

@ -1,24 +1,30 @@
{ {
"name": "GNOME", "name": "GNOME",
"url": "https://help.gnome.org/users/gnome-help/stable/shell-keyboard-shortcuts.html.en",
"shortcuts": { "shortcuts": {
"ctrl+alt+t": "Terminal", "super+t": "* Terminal",
"ctrl+alt+d": "Show Desktop", "super+f": "* Files",
"super+r": "* Run Command",
"super": "Activities Overview", "super": "Activities Overview",
"super+a": "Applications", "super+d": "Show Desktop",
"super+f": "Files", "super+a": "Show Applications",
"super+t": "Terminal",
"super+l": "Lock Screen", "super+l": "Lock Screen",
"super+shift+q": "Log Out", "super+shift+q": "Log Out",
"super+shift+d": "Show Applications",
"super+page up": "Switch Workspace on the right", "super+page up": "Switch Workspace on the right",
"super+page down": "Switch Workspace on the left", "super+page down": "Switch Workspace on the left",
"super+1-9": "Switch to Workspace 1-9", "super+1": "Open Email",
"ctrl+alt+arrow": "Switch Workspace", "super+2": "Open Calendar",
"ctrl+alt+up": "Maximize Window", "super+3": "Open Contacts",
"ctrl+alt+down": "Unmaximize Window", "super+4": "Open Photos",
"alt+tab": "Switch Applications", "super+5": "Open Files Manager",
"alt+`": "Switch Windows of the Same Application", "super+6": "Open Browser",
"alt+f2": "Run Command", "super+7": "Open Settings",
"super+8": "Open Terminal",
"super+9": "Open Dashboard",
"super+up": "Maximize Window",
"super+h": "Hide Window",
"super+tab": "Switch Applications",
"super+`": "Switch Windows of the Same Application",
"ctrl+alt+delete": "Log Out/Power Off/Restart", "ctrl+alt+delete": "Log Out/Power Off/Restart",
"ctrl+c": "Copy", "ctrl+c": "Copy",
"ctrl+v": "Paste", "ctrl+v": "Paste",

View File

@ -1,5 +1,6 @@
{ {
"name": "Kitty Terminal", "name": "Kitty Terminal",
"url": "https://github.com/jmcastagnetto/kitty-terminal-cheatsheet/blob/fbdf2e6ed4c6ef07d01a9eca7d07fc1e889769ed/kitty-terminal-cheatsheet.pdf",
"shortcuts": { "shortcuts": {
"Ctrl+Shift+T": "New tab", "Ctrl+Shift+T": "New tab",
"Ctrl+Shift+W": "Close tab", "Ctrl+Shift+W": "Close tab",

View File

@ -1,5 +1,6 @@
{ {
"name": "Neovim", "name": "Neovim",
"url": "https://cheatography.com/dcschmid/cheat-sheets/personal-neovim-cheatsheet/pdf/",
"shortcuts": { "shortcuts": {
"i": "Insert mode", "i": "Insert mode",
"esc": "Normal mode", "esc": "Normal mode",

View File

@ -1,13 +1,14 @@
{ {
"name": "Visual Studio Code", "name": "vscode",
"url": "https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf",
"shortcuts": { "shortcuts": {
"Ctrl+Shift+P": "Command Palette", "Ctrl+Shift+P": "Command Palette",
"Ctrl+k Ctrl+R": "Help Keyboard Shortcuts Reference",
"Ctrl+Shift+N": "New Window", "Ctrl+Shift+N": "New Window",
"Ctrl+Shift+W": "Close Window", "Ctrl+Shift+W": "Close Window",
"Ctrl+Shift+T": "Reopen Closed Editor", "Ctrl+Shift+T": "Reopen Closed Editor",
"Ctrl+Tab": "Switch Editor", "Ctrl+Tab": "Switch Editor",
"Ctrl+Shift+Tab": "Switch Editor in Reverse Order", "Ctrl+Shift+Tab": "Switch Editor in Reverse Order",
"Ctrl+Shift+M": "Toggle Problems Panel",
"Ctrl+Shift+G": "Toggle Source Control", "Ctrl+Shift+G": "Toggle Source Control",
"Ctrl+Shift+D": "Toggle Debug", "Ctrl+Shift+D": "Toggle Debug",
"Ctrl+Shift+X": "Toggle Extensions", "Ctrl+Shift+X": "Toggle Extensions",
@ -22,7 +23,6 @@
"Ctrl+Shift+O": "Go to Symbol", "Ctrl+Shift+O": "Go to Symbol",
"Ctrl+Shift+M": "Show Problems", "Ctrl+Shift+M": "Show Problems",
"Ctrl+Shift+J": "Toggle Search Details", "Ctrl+Shift+J": "Toggle Search Details",
"Ctrl+Shift+D": "Duplicate Line or Selection",
"Alt+Up": "Move Line Up", "Alt+Up": "Move Line Up",
"Alt+Down": "Move Line Down", "Alt+Down": "Move Line Down",
"Ctrl+Shift+K": "Delete Line", "Ctrl+Shift+K": "Delete Line",

BIN
scut

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
9e47bb0036eddd0391f5018caec3168c6324295daa31d7864c711d766f5bc0ca scut-latest.zip 339eb7a4e1c68c6a23dcd0487f5df2cb368d091f3044d62608d7a704f040b22e scut-latest.zip

53
scut.go
View File

@ -15,6 +15,7 @@ import (
type App struct { type App struct {
Name string `json:"name"` Name string `json:"name"`
Shortcuts map[string]string `json:"shortcuts"` Shortcuts map[string]string `json:"shortcuts"`
HelpUrl string `json:"url"`
} }
type Config struct { type Config struct {
@ -32,11 +33,34 @@ func getHomeDir() string {
} }
func getConfigScutDir() string { func getConfigScutDir() string {
var configDir string
// get home directory // get home directory
home := getHomeDir() home := getHomeDir()
homePathDir := home + "/.config/scut/config/"
// get config directory // get current directory of the binary
configDir := home + "/.config/scut/config/" ex, err := os.Executable()
if err != nil {
panic(err)
}
// get current directory of the binary without the binary name
exePathDir := strings.TrimSuffix(ex, filepath.Base(ex))
exePathDir = exePathDir + "config/"
//if exePathDir existe alors on utilise le répertoire config du binaire
if _, err := os.Stat(exePathDir); err == nil {
configDir = exePathDir
//si non si homePathDir existe alors on utilise le répertoire config du home
} else if _, err := os.Stat(homePathDir); err == nil {
configDir = homePathDir
//si non on utilise le répertoire config du binaire
} else {
configDir = ""
}
return configDir return configDir
} }
@ -56,6 +80,7 @@ func loadConfig(dir string) Config {
for _, file := range files { for _, file := range files {
if filepath.Ext(file.Name()) == ".json" { if filepath.Ext(file.Name()) == ".json" {
data, _ := ioutil.ReadFile(dir + "/" + file.Name()) data, _ := ioutil.ReadFile(dir + "/" + file.Name())
var app App var app App
json.Unmarshal(data, &app) json.Unmarshal(data, &app)
apps = append(apps, app) apps = append(apps, app)
@ -64,6 +89,7 @@ func loadConfig(dir string) Config {
config := Config{ config := Config{
Apps: apps, Apps: apps,
} }
return config return config
} }
@ -81,6 +107,7 @@ func main() {
fmt.Printf(" -c PathDuDossierConfig || Path du dossier de configuration au lieu du répertoire ./config (par défaut)\n") fmt.Printf(" -c PathDuDossierConfig || Path du dossier de configuration au lieu du répertoire ./config (par défaut)\n")
fmt.Printf(" -a Nom Application || Afficher les raccourcis de l'application spécifiée\n") fmt.Printf(" -a Nom Application || Afficher les raccourcis de l'application spécifiée\n")
fmt.Printf(" -f fitre || Filtrer les raccourcis qui contiennent le filtre\n") fmt.Printf(" -f fitre || Filtrer les raccourcis qui contiennent le filtre\n")
fmt.Printf(" -u || Afficher les URLs des raccourcis de chaque applications\n")
fmt.Printf(" -h || Afficher cette aide\n") fmt.Printf(" -h || Afficher cette aide\n")
fmt.Println("") fmt.Println("")
fmt.Println(" Example :") fmt.Println(" Example :")
@ -97,15 +124,34 @@ func main() {
appName := flag.String("a", "", "Application name") appName := flag.String("a", "", "Application name")
filter := flag.String("f", "", "Filter") filter := flag.String("f", "", "Filter")
urls := flag.Bool("u", false, "Afficher les URLs d'aide des raccourcis de chaque applications")
flag.Parse() flag.Parse()
fmt.Println(*configDir)
config := loadConfig(*configDir) config := loadConfig(*configDir)
cleanFilter := strings.TrimFunc(*filter, func(r rune) bool { cleanFilter := strings.TrimFunc(*filter, func(r rune) bool {
return !unicode.IsGraphic(r) return !unicode.IsGraphic(r)
}) })
if *appName == "" { if *urls == true {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 10, '.', 0)
fmt.Println(underline)
fmt.Println(" U R L S")
fmt.Println(underline)
for _, app := range config.Apps {
// fmt.Printf("%s %s\n", app.Name, app.HelpUrl)
fmt.Fprintf(w, "%s \t %s\n", app.Name, app.HelpUrl)
}
w.Flush()
} else if *appName == "" {
// List all applications // List all applications
fmt.Println(underline) fmt.Println(underline)
fmt.Println(" A P P L I C A T I O N S") fmt.Println(" A P P L I C A T I O N S")
@ -114,6 +160,7 @@ func main() {
fmt.Printf("%s\n", app.Name) fmt.Printf("%s\n", app.Name)
} }
fmt.Println() fmt.Println()
} else { } else {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 10, '.', 0) w := tabwriter.NewWriter(os.Stdout, 0, 0, 10, '.', 0)
if *filter != "" { if *filter != "" {