diff --git a/README.md b/README.md index 471b064..c7ce435 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,13 @@ Scut-Reminder est un petit utilitaire en ligne de commande pour gérer et lister ## Usage ``` -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 // 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 -u // Afficher liste des urls d'aide au raccourcis ``` ## Options diff --git a/config/gnome.json b/config/gnome.json index ba3236b..97dd87e 100644 --- a/config/gnome.json +++ b/config/gnome.json @@ -1,24 +1,30 @@ { "name": "GNOME", + "url": "https://help.gnome.org/users/gnome-help/stable/shell-keyboard-shortcuts.html.en", "shortcuts": { - "ctrl+alt+t": "Terminal", - "ctrl+alt+d": "Show Desktop", + "super+t": "* Terminal", + "super+f": "* Files", + "super+r": "* Run Command", "super": "Activities Overview", - "super+a": "Applications", - "super+f": "Files", - "super+t": "Terminal", + "super+d": "Show Desktop", + "super+a": "Show Applications", "super+l": "Lock Screen", "super+shift+q": "Log Out", - "super+shift+d": "Show Applications", "super+page up": "Switch Workspace on the right", "super+page down": "Switch Workspace on the left", - "super+1-9": "Switch to Workspace 1-9", - "ctrl+alt+arrow": "Switch Workspace", - "ctrl+alt+up": "Maximize Window", - "ctrl+alt+down": "Unmaximize Window", - "alt+tab": "Switch Applications", - "alt+`": "Switch Windows of the Same Application", - "alt+f2": "Run Command", + "super+1": "Open Email", + "super+2": "Open Calendar", + "super+3": "Open Contacts", + "super+4": "Open Photos", + "super+5": "Open Files Manager", + "super+6": "Open Browser", + "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+c": "Copy", "ctrl+v": "Paste", diff --git a/config/kitty.json b/config/kitty.json index 88ea245..b4dd4ea 100644 --- a/config/kitty.json +++ b/config/kitty.json @@ -1,5 +1,6 @@ { "name": "Kitty Terminal", + "url": "https://github.com/jmcastagnetto/kitty-terminal-cheatsheet/blob/fbdf2e6ed4c6ef07d01a9eca7d07fc1e889769ed/kitty-terminal-cheatsheet.pdf", "shortcuts": { "Ctrl+Shift+T": "New tab", "Ctrl+Shift+W": "Close tab", diff --git a/config/neovim.json b/config/neovim.json index 0509c60..506a894 100644 --- a/config/neovim.json +++ b/config/neovim.json @@ -1,5 +1,6 @@ { "name": "Neovim", + "url": "https://cheatography.com/dcschmid/cheat-sheets/personal-neovim-cheatsheet/pdf/", "shortcuts": { "i": "Insert mode", "esc": "Normal mode", diff --git a/config/vscode.json b/config/vscode.json index f28d3a3..3acafd6 100644 --- a/config/vscode.json +++ b/config/vscode.json @@ -1,13 +1,14 @@ { - "name": "Visual Studio Code", + "name": "vscode", + "url": "https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf", "shortcuts": { "Ctrl+Shift+P": "Command Palette", + "Ctrl+k Ctrl+R": "Help Keyboard Shortcuts Reference", "Ctrl+Shift+N": "New Window", "Ctrl+Shift+W": "Close Window", "Ctrl+Shift+T": "Reopen Closed Editor", "Ctrl+Tab": "Switch Editor", "Ctrl+Shift+Tab": "Switch Editor in Reverse Order", - "Ctrl+Shift+M": "Toggle Problems Panel", "Ctrl+Shift+G": "Toggle Source Control", "Ctrl+Shift+D": "Toggle Debug", "Ctrl+Shift+X": "Toggle Extensions", @@ -22,7 +23,6 @@ "Ctrl+Shift+O": "Go to Symbol", "Ctrl+Shift+M": "Show Problems", "Ctrl+Shift+J": "Toggle Search Details", - "Ctrl+Shift+D": "Duplicate Line or Selection", "Alt+Up": "Move Line Up", "Alt+Down": "Move Line Down", "Ctrl+Shift+K": "Delete Line", diff --git a/scut b/scut index 3c2b290..7e78f72 100755 Binary files a/scut and b/scut differ diff --git a/scut-latest.zip b/scut-latest.zip index b0cb6a8..8793aad 100644 Binary files a/scut-latest.zip and b/scut-latest.zip differ diff --git a/scut-latest.zip.sha256 b/scut-latest.zip.sha256 index 798d448..46ddeae 100644 --- a/scut-latest.zip.sha256 +++ b/scut-latest.zip.sha256 @@ -1 +1 @@ -9e47bb0036eddd0391f5018caec3168c6324295daa31d7864c711d766f5bc0ca scut-latest.zip +339eb7a4e1c68c6a23dcd0487f5df2cb368d091f3044d62608d7a704f040b22e scut-latest.zip diff --git a/scut.go b/scut.go index d5e9ef8..bbf289a 100644 --- a/scut.go +++ b/scut.go @@ -15,6 +15,7 @@ import ( type App struct { Name string `json:"name"` Shortcuts map[string]string `json:"shortcuts"` + HelpUrl string `json:"url"` } type Config struct { @@ -32,11 +33,34 @@ func getHomeDir() string { } func getConfigScutDir() string { + + var configDir string + // get home directory home := getHomeDir() + homePathDir := home + "/.config/scut/config/" - // get config directory - configDir := home + "/.config/scut/config/" + // get current directory of the binary + 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 } @@ -56,6 +80,7 @@ func loadConfig(dir string) Config { for _, file := range files { if filepath.Ext(file.Name()) == ".json" { data, _ := ioutil.ReadFile(dir + "/" + file.Name()) + var app App json.Unmarshal(data, &app) apps = append(apps, app) @@ -64,6 +89,7 @@ func loadConfig(dir string) Config { config := Config{ Apps: apps, } + 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(" -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(" -u || Afficher les URLs des raccourcis de chaque applications\n") fmt.Printf(" -h || Afficher cette aide\n") fmt.Println("") fmt.Println(" Example :") @@ -97,15 +124,34 @@ func main() { appName := flag.String("a", "", "Application name") filter := flag.String("f", "", "Filter") + + urls := flag.Bool("u", false, "Afficher les URLs d'aide des raccourcis de chaque applications") + flag.Parse() + fmt.Println(*configDir) + config := loadConfig(*configDir) cleanFilter := strings.TrimFunc(*filter, func(r rune) bool { 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 fmt.Println(underline) 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.Println() + } else { w := tabwriter.NewWriter(os.Stdout, 0, 0, 10, '.', 0) if *filter != "" {