[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RP] Ratmenu keyboard shortcuts
From: |
Gillian Seed |
Subject: |
Re: [RP] Ratmenu keyboard shortcuts |
Date: |
Sun, 7 Apr 2013 13:03:07 +0300 |
Hi,
Sorry about HTML post, haven't used the mailing lists a lot. I wasn't able to
find the original patch. I even contacted to author but he didn't neither had
it archived, so I made one of my own. To use this patch, format of the ratmenu
should be as follows,
#!/bin/bash
#
./ratmenu \
-label Menu \
"vi v" "vim" -shortcut v \
"nano n" "nano" -shortcut n \
"hex " "hexedit"
where v now will be shortcut to vim and n shortcut to nano. If you find any
bugs, please let me know.
--- ratmenu.c 2010-03-18 05:43:03.000000000 +0200
+++ ratmenu_shortcut.c 2013-04-07 12:23:55.000000000 +0300
@@ -107,6 +107,7 @@
char **labels; /* list of labels and commands */
char **commands;
+char *shortcuts; /* list of shortcuts */
int numitems;
int startitem; /* which item to highlight first */
int curitem;
@@ -229,20 +230,30 @@
usage();
numitems = (argc-i) / 2;
-
+
labels = (char **) malloc(numitems * sizeof(char *));
commands = (char **) malloc(numitems * sizeof(char *));
+ shortcuts = malloc(numitems * sizeof(char *));
- if (commands == NULL || labels == NULL) {
+ if (commands == NULL || labels == NULL || shortcuts == NULL) {
fprintf(stderr, "%s: no memory!\n", progname);
exit(1);
}
-
+
for (j=0; i < argc; j++) {
labels[j] = argv[i++];
commands[j] = argv[i++];
+ if(i < argc) {
+ if(strcmp(argv[i], "-shortcut") == 0) {
+ shortcuts[j] = argv[i+1][0];
+ numitems--;
+ i=i+2;
+ } else {
+ shortcuts[j] = '\0';
+ }
+ }
}
-
+
dpy = XOpenDisplay(displayname);
if (dpy == NULL) {
fprintf(stderr, "%s: cannot open display", progname);
@@ -406,6 +417,13 @@
case CTL('b'):
key = XK_Left;
break;
+ default:
+ for(i = 0; i < numitems; i++){
+ if(keystr[0] == shortcuts[i]) {
+ spawn(commands[i]);
+ }
+ }
+ break;
}
}
BR,
Gillian
ratmenu_shortcut.patch
Description: Binary data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [RP] Ratmenu keyboard shortcuts,
Gillian Seed <=