]> git.madduck.net Git - etc/awesome.git/blob - Utilities.md

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

84fe3faea788ed965388c93b9847319a822d1702
[etc/awesome.git] / Utilities.md
1 markup
2 ------
3
4 Made markup easier!
5
6 First, require it like this:
7
8     local markup = lain.util.markup
9
10 then you can call its functions:
11
12      +-- markup
13      |
14      |`-- bold()        Set bold.
15      |`-- italic()      Set italicized text.
16      |`-- strike()      Set strikethrough text.
17      |`-- underline()   Set underlined text.
18      |`-- monospace()   Set monospaced text.
19      |`-- big()         Set bigger text.
20      |`-- small()       Set smaller text.
21      |`-- font()        Set the font of the text.
22      |
23      |`--+ bg
24      |   |
25      |   |`-- color()   Set background color.
26      |   |`-- focus()   Set focus  background color.
27      |   |`-- normal()  Set normal background color.
28      |    `-- urgent()  Set urgent background color.
29      |
30      |`--+ fg
31      |   |
32      |   |`-- color()   Set foreground color.
33      |   |`-- focus()   Set focus  foreground color.
34      |   |`-- normal()  Set normal foreground color.
35      |    `-- urgent()  Set urgent foreground color.
36      |
37      |`-- focus()       Set both foreground and background focus  colors.
38      |`-- normal()      Set both foreground and background normal colors.
39       `-- urgent()      Set both foreground and background urgent colors.
40
41 they all take one argument, which is the text to markup, except `fg.color` and `bg.color`:
42
43     markup.fg.color(text, color)
44     markup.bg.color(text, color)
45
46 dynamic tagging
47 ---------------
48
49 That is:
50
51 - create a new tag;
52 - rename current tag;
53 - move current tag;
54 - delete current tag.
55
56 If you delete a tag, any rule set on it shall be broken, so be careful.
57
58 Use it with key bindings like these:
59
60     awful.key({ modkey, "Shift" }, "n", function () lain.util.create_tag(mypromptbox) end),
61     awful.key({ modkey, "Shift" }, "r", function () lain.util.rename_tag(mypromptbox) end),
62     awful.key({ modkey, "Shift" }, "r", function () lain.util.move_tag(1) end),  -- move next tag
63     awful.key({ modkey, "Shift" }, "r", function () lain.util.move_tag(-1) end), -- move prev tag
64     awful.key({ modkey, "Shift" }, "d", function () lain.util.delete_tag() end),
65
66 useless\_gaps\_resize
67 ---------------------
68
69 Changes `beautiful.useless_gaps_width` on the fly.
70
71 The function takes an integer argument, being the amount of pixel to add/remove to gaps.
72
73 You could use it with these keybindings:
74
75     -- On the fly useless gaps change
76     awful.key({ altkey, "Control" }, "+", function () lain.util.useless_gaps_resize(1) end),
77     awful.key({ altkey, "Control" }, "-", function () lain.util.useless_gaps_resize(-1) end),
78
79 where `altkey=Mod1`, or you could use it like this:
80
81     mywidget:buttons(awful.util.table.join (
82           awful.button({}, 4, function() lain.util.useless_gaps_resize(-1) end),
83           awful.button({}, 5, function() lain.util.useless_gaps_resize(1) end)
84           end)
85     ))
86
87 so when hovering the mouse over `mywidget`, you can adjust useless gaps size by scrolling with the mouse wheel.
88
89 tag\_view\_nonempty
90 -------------------
91
92 This function lets you jump to the next/previous non-empty tag.
93 It takes two arguments:
94
95 * `direction`: `1` for next non-empty tag, `-1` for previous.
96 * `sc`: Screen which the taglist is in. Default is `mouse.screen` or `1`. This
97   argument is optional.
98
99 You can use it with key bindings like these:
100
101     -- Non-empty tag browsing
102     awful.key({ altkey }, "Left", function () lain.util.tag_view_nonempty(-1) end),
103     awful.key({ altkey }, "Right", function () lain.util.tag_view_nonempty(1) end),
104
105 where `altkey = "Mod1"`.
106
107 menu\_clients\_current\_tags
108 ----------------------------
109
110 Similar to `awful.menu.clients`, but this menu only shows the clients
111 of currently visible tags. Use it with a key binding like this:
112
113     awful.key({ "Mod1" }, "Tab",
114     function()
115         awful.menu.menu_keys.down = { "Down", "Alt_L", "Tab", "j" }
116         awful.menu.menu_keys.up = { "Up", "k" }
117         lain.util.menu_clients_current_tags({ width = 350 }, { keygrabber = true })
118     end),
119
120 magnify\_client
121 ---------------
122
123 Set a client to floating and resize it in the same way the "magnifier"
124 layout does it. Place it on the "current" screen (derived from the mouse
125 position). This allows you to magnify any client you wish, regardless of
126 the currently used layout. Use it with a client keybinding like this:
127
128         clientkeys = awful.util.table.join(
129                 ...
130                 awful.key({ modkey, "Control" }, "m", lain.util.magnify_client),
131                 ...
132         )
133
134 If you want to "de-magnify" it, just retype the keybinding.
135
136 niceborder\_{focus, unfocus}
137 ----------------------------
138
139 By default, your `rc.lua` contains something like this:
140
141         client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
142         client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
143
144 You can change it to this:
145
146         client.connect_signal("focus", lain.util.niceborder_focus(c))
147         client.connect_signal("unfocus", lain.util.niceborder_unfocus(c))
148
149 Now, when a client is focused or unfocused, Awesome will look up its
150 nice value in `/proc/<pid>/stat`. If it's less than 0, the client is
151 classified as "high priority"; if it's greater than 0, the client is
152 classified as "low priority". If it's equal to 0, nothing special
153 happens.
154
155 This requires to define additional colors in your `theme.lua`. For example:
156
157         theme.border_focus_highprio  = "#FF0000"
158         theme.border_normal_highprio = "#A03333"
159
160         theme.border_focus_lowprio   = "#3333FF"
161         theme.border_normal_lowprio  = "#333366"