wmcliphist: Add -b command line option to select which clipboard to manage.
This commit is contained in:
parent
a32b41a0a2
commit
48a0ccca75
|
@ -48,7 +48,7 @@ dump_history_list_fn(char *header)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
my_get_selection_text(GtkClipboard *clipboard, const gchar *text, gpointer
|
my_get_selection_text(GtkClipboard *cb, const gchar *text, gpointer
|
||||||
data)
|
data)
|
||||||
{
|
{
|
||||||
/* previous clipboard content */
|
/* previous clipboard content */
|
||||||
|
@ -86,7 +86,7 @@ my_get_selection_text(GtkClipboard *clipboard, const gchar *text, gpointer
|
||||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_ignore)) ||
|
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_ignore)) ||
|
||||||
gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_lock))) {
|
gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_lock))) {
|
||||||
if (gtk_selection_owner_set(dock_app,
|
if (gtk_selection_owner_set(dock_app,
|
||||||
GDK_SELECTION_PRIMARY,
|
clipboard,
|
||||||
GDK_CURRENT_TIME) == 0)
|
GDK_CURRENT_TIME) == 0)
|
||||||
selected = NULL;
|
selected = NULL;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ my_get_xselection(GtkWidget *window, GdkEvent *event)
|
||||||
|
|
||||||
begin_func("my_get_xselection");
|
begin_func("my_get_xselection");
|
||||||
|
|
||||||
gtk_clipboard_request_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY),
|
gtk_clipboard_request_text(gtk_clipboard_get(clipboard),
|
||||||
my_get_selection_text, NULL);
|
my_get_selection_text, NULL);
|
||||||
|
|
||||||
return_val(TRUE);
|
return_val(TRUE);
|
||||||
|
@ -143,7 +143,7 @@ my_get_xselection(GtkWidget *window, GdkEvent *event)
|
||||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_ignore)) ||
|
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_ignore)) ||
|
||||||
gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_lock))) {
|
gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_lock))) {
|
||||||
if (gtk_selection_owner_set(dock_app,
|
if (gtk_selection_owner_set(dock_app,
|
||||||
GDK_SELECTION_PRIMARY,
|
clipboard,
|
||||||
GDK_CURRENT_TIME) == 0)
|
GDK_CURRENT_TIME) == 0)
|
||||||
selected = NULL;
|
selected = NULL;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ time_conv_select()
|
||||||
begin_func("time_conv_select");
|
begin_func("time_conv_select");
|
||||||
|
|
||||||
gtk_selection_convert(main_window,
|
gtk_selection_convert(main_window,
|
||||||
GDK_SELECTION_PRIMARY,
|
clipboard,
|
||||||
GDK_TARGET_STRING,
|
GDK_TARGET_STRING,
|
||||||
GDK_CURRENT_TIME);
|
GDK_CURRENT_TIME);
|
||||||
return_val(TRUE);
|
return_val(TRUE);
|
||||||
|
|
|
@ -33,6 +33,10 @@ GtkWidget *button;
|
||||||
/* pixmap */
|
/* pixmap */
|
||||||
GtkWidget *pixmap;
|
GtkWidget *pixmap;
|
||||||
|
|
||||||
|
/* which clipboard to use */
|
||||||
|
gchar clipboard_str[32] = DEF_CLIPBOARD_STR;
|
||||||
|
GdkAtom clipboard;
|
||||||
|
|
||||||
/* ==========================================================================
|
/* ==========================================================================
|
||||||
* clipboard history menu
|
* clipboard history menu
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -51,7 +51,7 @@ process_item(char *content, gint locked, gboolean exec)
|
||||||
if (auto_take_up == 1) {
|
if (auto_take_up == 1) {
|
||||||
selected = hist_item;
|
selected = hist_item;
|
||||||
if (gtk_selection_owner_set(dock_app,
|
if (gtk_selection_owner_set(dock_app,
|
||||||
GDK_SELECTION_PRIMARY,
|
clipboard,
|
||||||
GDK_CURRENT_TIME) == 0) {
|
GDK_CURRENT_TIME) == 0) {
|
||||||
selected = NULL;
|
selected = NULL;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ process_item(char *content, gint locked, gboolean exec)
|
||||||
if (auto_take_up == 1) {
|
if (auto_take_up == 1) {
|
||||||
selected = hist_item;
|
selected = hist_item;
|
||||||
if (gtk_selection_owner_set(dock_app,
|
if (gtk_selection_owner_set(dock_app,
|
||||||
GDK_SELECTION_PRIMARY,
|
clipboard,
|
||||||
GDK_CURRENT_TIME) == 0) {
|
GDK_CURRENT_TIME) == 0) {
|
||||||
selected = NULL;
|
selected = NULL;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ move_item_to_begin(HISTORY_ITEM *item) {
|
||||||
history_items = g_list_concat(list_node, history_items);
|
history_items = g_list_concat(list_node, history_items);
|
||||||
selected = item;
|
selected = item;
|
||||||
if (gtk_selection_owner_set(dock_app,
|
if (gtk_selection_owner_set(dock_app,
|
||||||
GDK_SELECTION_PRIMARY,
|
clipboard,
|
||||||
GDK_CURRENT_TIME) == 0)
|
GDK_CURRENT_TIME) == 0)
|
||||||
selected = NULL;
|
selected = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,6 +178,9 @@ rcconfig_get(char *fname)
|
||||||
} else if (strcmp(direc_buf, "lcolor") == 0) {
|
} else if (strcmp(direc_buf, "lcolor") == 0) {
|
||||||
state = STATE_VALUE;
|
state = STATE_VALUE;
|
||||||
buf_index = 0;
|
buf_index = 0;
|
||||||
|
} else if (strcmp(direc_buf, "clipboard") == 0) {
|
||||||
|
state = STATE_VALUE;
|
||||||
|
buf_index = 0;
|
||||||
} else if (strcmp(direc_buf, "autosave") == 0) {
|
} else if (strcmp(direc_buf, "autosave") == 0) {
|
||||||
state = STATE_VALUE;
|
state = STATE_VALUE;
|
||||||
buf_index = 0;
|
buf_index = 0;
|
||||||
|
@ -229,6 +232,11 @@ rcconfig_get(char *fname)
|
||||||
memset(locked_color_str, 0, 32);
|
memset(locked_color_str, 0, 32);
|
||||||
strncpy(locked_color_str,
|
strncpy(locked_color_str,
|
||||||
expr_buf, 31);
|
expr_buf, 31);
|
||||||
|
} else if (strcmp(direc_buf, "clipboard")
|
||||||
|
== 0) {
|
||||||
|
memset(clipboard_str, 0, 32);
|
||||||
|
strncpy(clipboard_str,
|
||||||
|
expr_buf, 31);
|
||||||
} else if (strcmp(direc_buf, "autosave") == 0) {
|
} else if (strcmp(direc_buf, "autosave") == 0) {
|
||||||
autosave_period =
|
autosave_period =
|
||||||
atoi(expr_buf);
|
atoi(expr_buf);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
wmcliphist \(em provides a history to X11 selections
|
wmcliphist \(em provides a history to X11 selections
|
||||||
.SH "SYNOPSIS"
|
.SH "SYNOPSIS"
|
||||||
.PP
|
.PP
|
||||||
\fBwmcliphist\fR [\fB-h\fP] [\fB-v\fP] [\fB-n \fInum\fR\fP] [\fB-c \fIcol\fR\fP] [\fB-i \fInum\fR\fP] [\fB-s \fIsize\fR\fP]
|
\fBwmcliphist\fR [\fB-h\fP] [\fB-v\fP] [\fB-n \fInum\fR\fP] [\fB-c \fIcol\fR\fP] [\fB-i \fInum\fR\fP] [\fB-s \fIsize\fR\fP] [\fB-b \fIclipboard\fR\fP]
|
||||||
.SH "DESCRIPTION"
|
.SH "DESCRIPTION"
|
||||||
.PP
|
.PP
|
||||||
This manual page documents briefly the program
|
This manual page documents briefly the program
|
||||||
|
@ -39,6 +39,10 @@ choose num=1 and for light backgrounds num=2.
|
||||||
.IP "\fB-s size\fP " 10
|
.IP "\fB-s size\fP " 10
|
||||||
Choose wmcliphist icon size, must be one of 16, 30,
|
Choose wmcliphist icon size, must be one of 16, 30,
|
||||||
40 or 60 (default).
|
40 or 60 (default).
|
||||||
|
.IP "\fB-b clipboard\fP " 10
|
||||||
|
Choose clipboard to use, must be one of PRIMARY (select copies, middle click
|
||||||
|
pastes, default), SECONDARY (not used), or CLIPBOARD (Ctrl+C copies,
|
||||||
|
Ctrl+V pastes)
|
||||||
|
|
||||||
.SH "AUTHOR"
|
.SH "AUTHOR"
|
||||||
.PP
|
.PP
|
||||||
|
|
|
@ -32,8 +32,11 @@ print_help()
|
||||||
" 1 = for dark background\n"
|
" 1 = for dark background\n"
|
||||||
" 2 = for light background\n");
|
" 2 = for light background\n");
|
||||||
fprintf(stderr, "-d dumps clipboard history to stdout"
|
fprintf(stderr, "-d dumps clipboard history to stdout"
|
||||||
" in pseudo XML format (no escaping etc.)\n\n");
|
" in pseudo XML format (no escaping etc.)\n");
|
||||||
|
fprintf(stderr, "-b <type> choose clipboard to manage\n"
|
||||||
|
" PRIMARY = select copies, middle click pastes (default)\n"
|
||||||
|
" SECONDARY = not used\n"
|
||||||
|
" CLIPBOARD = Ctrl+C copies, Ctrl+V pastes\n\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
return_void();
|
return_void();
|
||||||
}
|
}
|
||||||
|
@ -169,6 +172,14 @@ main(int argc, char **argv)
|
||||||
} else if (*(arg + 1) == 'v') {
|
} else if (*(arg + 1) == 'v') {
|
||||||
printf("wmcliphist "WMCLIPHIST_VERSION"\n");
|
printf("wmcliphist "WMCLIPHIST_VERSION"\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
} else if (*(arg + 1) == 'b') {
|
||||||
|
i++;
|
||||||
|
if (!argv[i]) {
|
||||||
|
fprintf(stderr, "Missing value of -b\n");
|
||||||
|
print_help();
|
||||||
|
}
|
||||||
|
memset(clipboard_str, 0, 32);
|
||||||
|
strncpy(clipboard_str, argv[i], 31);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Invalid option -%c\n", *(arg + 1));
|
fprintf(stderr, "Invalid option -%c\n", *(arg + 1));
|
||||||
print_help();
|
print_help();
|
||||||
|
@ -318,6 +329,25 @@ main(int argc, char **argv)
|
||||||
gdk_rgba_parse(&locked_color, locked_color_str);
|
gdk_rgba_parse(&locked_color, locked_color_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set clipboard */
|
||||||
|
if (strcmp(clipboard_str, "PRIMARY") == 0) {
|
||||||
|
clipboard = GDK_SELECTION_PRIMARY;
|
||||||
|
} else if (strcmp(clipboard_str, "SECONDARY") == 0) {
|
||||||
|
clipboard = GDK_SELECTION_SECONDARY;
|
||||||
|
} else if (strcmp(clipboard_str, "CLIPBOARD") == 0) {
|
||||||
|
clipboard = GDK_SELECTION_CLIPBOARD;
|
||||||
|
} else {
|
||||||
|
char msg_str[128];
|
||||||
|
|
||||||
|
sprintf(msg_str, "Invalid clipboard string: '%s'.\n"
|
||||||
|
"Falling back to default ("
|
||||||
|
DEF_CLIPBOARD_STR
|
||||||
|
").",
|
||||||
|
clipboard_str);
|
||||||
|
show_message(msg_str, "Warning", "OK", NULL, NULL);
|
||||||
|
clipboard = DEF_CLIPBOARD;
|
||||||
|
}
|
||||||
|
|
||||||
/* load previously saved history */
|
/* load previously saved history */
|
||||||
if (history_load(dump_only) != 0) {
|
if (history_load(dump_only) != 0) {
|
||||||
if (errno == E_TOO_MUCH) {
|
if (errno == E_TOO_MUCH) {
|
||||||
|
@ -377,7 +407,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
/* setup everything for supplying selection to other apps */
|
/* setup everything for supplying selection to other apps */
|
||||||
gtk_selection_add_target(dock_app,
|
gtk_selection_add_target(dock_app,
|
||||||
GDK_SELECTION_PRIMARY,
|
clipboard,
|
||||||
GDK_SELECTION_TYPE_STRING,
|
GDK_SELECTION_TYPE_STRING,
|
||||||
1);
|
1);
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#define DEF_MENUKEY "Control+Alt+V"
|
#define DEF_MENUKEY "Control+Alt+V"
|
||||||
#define DEF_PREV_ITEM_KEY "Control+Alt+C"
|
#define DEF_PREV_ITEM_KEY "Control+Alt+C"
|
||||||
#define DEF_EXEC_ITEM_KEY "Control+Alt+E"
|
#define DEF_EXEC_ITEM_KEY "Control+Alt+E"
|
||||||
|
#define DEF_CLIPBOARD_STR "PRIMARY"
|
||||||
|
#define DEF_CLIPBOARD GDK_SELECTION_PRIMARY
|
||||||
#define MAX_ITEM_LENGTH 40
|
#define MAX_ITEM_LENGTH 40
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,6 +65,9 @@ extern HISTORY_ITEM *selected;
|
||||||
extern gint locked_count;
|
extern gint locked_count;
|
||||||
|
|
||||||
|
|
||||||
|
/* which clipboard to use */
|
||||||
|
extern gchar clipboard_str[32];
|
||||||
|
extern GdkAtom clipboard;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define dump_history_list(header) dump_history_list_fn(header)
|
#define dump_history_list(header) dump_history_list_fn(header)
|
||||||
|
|
|
@ -67,6 +67,11 @@ exec_middleclick yes
|
||||||
|
|
||||||
exec_hotkey yes
|
exec_hotkey yes
|
||||||
|
|
||||||
|
# Which clipboard should wmcliphist manage? PRIMARY (select copies, middle click
|
||||||
|
# pastes), SECONDARY (not used), or CLIPBOARD (Ctrl+C copies, Ctrl+V pastes)
|
||||||
|
# Default: PRIMARY
|
||||||
|
|
||||||
|
clipboard PRIMARY
|
||||||
|
|
||||||
# You can define regular expressions driven actions executed when new
|
# You can define regular expressions driven actions executed when new
|
||||||
# item is captured. Items can be silently ignored, inserted to submenus
|
# item is captured. Items can be silently ignored, inserted to submenus
|
||||||
|
|
Loading…
Reference in a new issue