[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] list_padding command
- To: herbstluftwm _minus_ devel _at_ lists _dot_ sourceforge _dot_ net
- Subject: [PATCH] list_padding command
- From: Florian Bruhin <me _at_ the _minus_ compiler _dot_ org>
- Date: Wed, 31 Oct 2012 07:02:41 +0100
1) be bored in train at 6 in the morning
2) implement list_padding for hlwm
3) ???
4) PROFIT!
Sorry if you need to copypaste the patch, don't have an MTA set up, so
no idea how to use git send-email correcly.
If anything is wrong or can be improved, let me know.
Sample output:
$ herbstclient list_padding
0: 24 0 0 0
1: 23 42 23 42
~Florian
--
O< ascii ribbon campaign - stop html mail www.asciiribbon.org
www.the-compiler.org | I love long mails http://email.is-not-s.ms/
I have a terrible headache, I was putting on toilet water and the lid fell.
>From c77878fc8a9fd4f8a911f28930cc7ad50cdd5fd7 Mon Sep 17 00:00:00 2001
From: Florian Bruhin <git _at_ the _minus_ compiler _dot_ org>
Date: Wed, 31 Oct 2012 06:52:38 +0100
Subject: [PATCH] new command: list_padding
---
NEWS | 1 +
doc/herbstluftwm.txt | 3 +++
src/command.c | 1 +
src/main.c | 1 +
src/monitor.c | 16 ++++++++++++++++
src/monitor.h | 1 +
6 files changed, 23 insertions(+)
diff --git a/NEWS b/NEWS
index 516769b..16ea50b 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,7 @@ Changes:
control, wether tag switching operations for a monitor are allowed.
* set the urgent flag on _NET_WM_STATE_DEMANDS_ATTENTION
* clear the urgent flag on window focus
+ * new command: list_padding
Release: 0.4.1 on 2012-08-30
----------------------------
diff --git a/doc/herbstluftwm.txt b/doc/herbstluftwm.txt
index c6d7b91..bf97816 100644
--- a/doc/herbstluftwm.txt
+++ b/doc/herbstluftwm.txt
@@ -507,6 +507,9 @@ pad 'INDEX' ['PADUP' ['PADRIGHT' ['PADDOWN' ['PADLEFT']]]]::
Sets the pad of indexed monitor to the specified padding. If no or an empty
padding is given, it is not changed.
+list_padding::
+ Lists the padding of all monitors.
+
layout ['TAG']::
Prints the layout of 'TAG' in a nice tree style. Its style is defined
by the 'tree_style' setting. If no 'TAG' is given, current tag is used.
diff --git a/src/command.c b/src/command.c
index 65caa28..27bba8f 100644
--- a/src/command.c
+++ b/src/command.c
@@ -57,6 +57,7 @@ struct {
{ "list_monitors", 0, no_completion },
{ "list_commands", 0, no_completion },
{ "list_keybinds", 0, no_completion },
+ { "list_padding", 0, no_completion },
{ "add_monitor", 7, no_completion },
{ "bring", 2, no_completion },
{ "focus_nth", 2, no_completion },
diff --git a/src/main.c b/src/main.c
index 6c41c1d..e6b0811 100644
--- a/src/main.c
+++ b/src/main.c
@@ -88,6 +88,7 @@ CommandBinding g_commands[] = {
CMD_BIND( "set_monitors", set_monitor_rects_command),
CMD_BIND( "disjoin_rects", disjoin_rects_command),
CMD_BIND( "list_keybinds", key_list_binds),
+ CMD_BIND( "list_padding", list_padding),
CMD_BIND_NO_OUTPUT( "keybind", keybind),
CMD_BIND_NO_OUTPUT( "keyunbind", keyunbind),
CMD_BIND_NO_OUTPUT( "mousebind", mouse_bind_command),
diff --git a/src/monitor.c b/src/monitor.c
index 256b5d0..d815329 100644
--- a/src/monitor.c
+++ b/src/monitor.c
@@ -115,6 +115,22 @@ int list_monitors(int argc, char** argv, GString* output) {
return 0;
}
+int list_padding(int argc, char** argv, GString* output) {
+ (void)argc;
+ (void)argv;
+ int i;
+ for (i = 0; i < g_monitors->len; i++) {
+ HSMonitor* monitor = monitor_with_index(i);
+ g_string_append_printf(output, "%d: %d %d %d %d\n",
+ i,
+ monitor->pad_up,
+ monitor->pad_right,
+ monitor->pad_down,
+ monitor->pad_left);
+ }
+ return 0;
+}
+
static bool rects_intersect(RectList* m1, RectList* m2) {
XRectangle *r1 = &m1->rect, *r2 = &m2->rect;
bool is = TRUE;
diff --git a/src/monitor.h b/src/monitor.h
index b46424f..53b8b3e 100644
--- a/src/monitor.h
+++ b/src/monitor.h
@@ -60,6 +60,7 @@ int monitor_raise_command(int argc, char** argv);
int remove_monitor_command(int argc, char** argv);
int remove_monitor(int index);
int list_monitors(int argc, char** argv, GString* output);
+int list_padding(int argc, char** argv, GString* output);
int set_monitor_rects_command(int argc, char** argv, GString* output);
int disjoin_rects_command(int argc, char** argv, GString* output);
int set_monitor_rects(XRectangle* templates, size_t count);
--
1.8.0