Initial commit
This commit is contained in:
commit
57b0bab65c
|
@ -0,0 +1,20 @@
|
|||
Copyright (c) 2016 Albert Diserholt
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,115 @@
|
|||
awesome-sharedtags
|
||||
==================
|
||||
|
||||
A simple implementation for creating tags shared on multiple screens for
|
||||
[awesome window manager](http://awesome.naquadah.org/).
|
||||
|
||||
It is designed to work with *awesome* version 3.5, but might work with older or
|
||||
newer versions as well.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Define a list of tags to be usable on all screens.
|
||||
* Move tags with all clients between screens.
|
||||
* Everything else should be just as usual.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
1. Clone or download a zip of the repository, and put the `sharedtags`
|
||||
directory somewhere where you can easily include it, for example in the same
|
||||
directory as your `rc.lua` file.
|
||||
2. Modify your `rc.lua` file. A [patch](rc.lua.patch) against the default
|
||||
configuration is included in the repository for easy comparison, but keep
|
||||
reading for a textual description.
|
||||
1. Require the `sharedtags` library somewhere at the top of the file.
|
||||
|
||||
```lua
|
||||
local sharedtags = require("sharedtags")
|
||||
```
|
||||
2. Create the tags using the `sharedtags()` method, instead of the original
|
||||
ones created with `awful.tag()`.
|
||||
|
||||
```lua
|
||||
local tags = sharedtags(
|
||||
{ name = "main", layout = layouts[2] },
|
||||
{ name = "www", layout = awful.layout.suit.max },
|
||||
{ name = "chat", screen = 2, layout = layouts[1] },
|
||||
{ layout = layouts[2] },
|
||||
{ screen = 2, layout = layouts[2] }
|
||||
)
|
||||
```
|
||||
3. The code for handling tags and clients needs to be changed to use the
|
||||
library.
|
||||
|
||||
```lua
|
||||
for i = 1, 9 do
|
||||
globalkeys = awful.util.table.join(globalkeys,
|
||||
-- View tag only.
|
||||
awful.key({ modkey }, "#" .. i + 9,
|
||||
function ()
|
||||
local tag = tags[i]
|
||||
if tag then
|
||||
sharedtags.viewonly(tag)
|
||||
end
|
||||
end),
|
||||
-- Toggle tag.
|
||||
awful.key({ modkey, "Control" }, "#" .. i + 9,
|
||||
function ()
|
||||
local tag = tags[i]
|
||||
if tag then
|
||||
sharedtags.viewtoggle(tag)
|
||||
end
|
||||
end),
|
||||
-- Move client to tag.
|
||||
awful.key({ modkey, "Shift" }, "#" .. i + 9,
|
||||
function ()
|
||||
if client.focus then
|
||||
local tag = tags[i]
|
||||
if tag then
|
||||
awful.client.movetotag(tag)
|
||||
end
|
||||
end
|
||||
end),
|
||||
-- Toggle tag.
|
||||
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
|
||||
function ()
|
||||
if client.focus then
|
||||
local tag = tags[i]
|
||||
if tag then
|
||||
awful.client.toggletag(tag)
|
||||
end
|
||||
end
|
||||
end))
|
||||
end
|
||||
```
|
||||
4. Lastly, since the tag list is now a one-dimensional array, any references
|
||||
to the `tags` array needs to be changed, for example in the rules section.
|
||||
|
||||
```lua
|
||||
awful.rules.rules = {
|
||||
-- Set Firefox to always map on tag number 2.
|
||||
{ rule = { class = "Firefox" },
|
||||
properties = { tag = tags[2] } },
|
||||
}
|
||||
```
|
||||
3. Restart or reload *awesome*.
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
Because of constraints in the X server, *awesome* does not allow
|
||||
toggling clients on tags allocated to other screens. Having a client on
|
||||
multiple tags and moving one of the tags will cause the client to move as well.
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
See [`doc/index.html`](doc/index.html) for API documentation.
|
||||
|
||||
Credits
|
||||
-------
|
||||
|
||||
Idea originally from https://github.com/lammermann/awesome-configs, but I could
|
||||
not get that implementation to work.
|
|
@ -0,0 +1,220 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>Reference</title>
|
||||
<link rel="stylesheet" href="ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>ldoc</h1>
|
||||
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><strong>sharedtags</strong></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>sharedtags</code></h1>
|
||||
<p>Provides functionality to share tags across all screens in awesome WM.</p>
|
||||
<p></p>
|
||||
<h3>Info:</h3>
|
||||
<ul>
|
||||
<li><strong>Copyright</strong>: 2016 Albert Diserholt</li>
|
||||
<li><strong>License</strong>: MIT</li>
|
||||
<li><strong>Author</strong>: Albert Diserholt</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#new">new (def)</a></td>
|
||||
<td class="summary">Create new tag objects.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#movetag">movetag (tag[, screen=capi.mouse.screen])</a></td>
|
||||
<td class="summary">Move the specified tag to a new screen, if necessary.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#viewonly">viewonly (tag[, screen=capi.mouse.screen])</a></td>
|
||||
<td class="summary">View the specified tag on the specified screen.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#viewtoggle">viewtoggle (tag[, screen=capi.mouse.screen])</a></td>
|
||||
<td class="summary">Toggle the specified tag on the specified screen.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "new"></a>
|
||||
<strong>new (def)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create new tag objects.
|
||||
The first tag defined for each screen will be automatically selected.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">def</span>
|
||||
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
A list of tables with the optional keys `name`, `layout`
|
||||
and `screen`. The `name` value is used to name the tag and defaults to the
|
||||
list index. The `layout` value sets the starting layout for the tag and
|
||||
defaults to the first layout. The `screen` value sets the starting screen
|
||||
for the tag and defaults to the first screen. The tags will be sorted in this
|
||||
order in the default taglist.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
A list of all created tags.
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example"> <span class="keyword">local</span> tags = sharedtags(
|
||||
<span class="comment">-- "main" is the first tag starting on screen 2 with the tile layout.
|
||||
</span> { name = <span class="string">"main"</span>, layout = awful.layout.suit.tile, screen = <span class="number">2</span> },
|
||||
<span class="comment">-- "www" is the second tag on screen 1 with the floating layout.
|
||||
</span> { name = <span class="string">"www"</span> },
|
||||
<span class="comment">-- Third tag is named "3" on screen 1 with the floating layout.
|
||||
</span> {})</pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "movetag"></a>
|
||||
<strong>movetag (tag[, screen=capi.mouse.screen])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Move the specified tag to a new screen, if necessary.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">tag</span>
|
||||
The tag to move.
|
||||
</li>
|
||||
<li><span class="parameter">screen</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
The screen to move the tag to.
|
||||
(<em>default</em> capi.mouse.screen)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><span class="type">bool</span></span>
|
||||
Whether the tag was moved.
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "viewonly"></a>
|
||||
<strong>viewonly (tag[, screen=capi.mouse.screen])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
View the specified tag on the specified screen.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">tag</span>
|
||||
The only tag to view.
|
||||
</li>
|
||||
<li><span class="parameter">screen</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
The screen to view the tag on.
|
||||
(<em>default</em> capi.mouse.screen)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "viewtoggle"></a>
|
||||
<strong>viewtoggle (tag[, screen=capi.mouse.screen])</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Toggle the specified tag on the specified screen.
|
||||
The tag will be selected if the screen changes, and toggled if it does not
|
||||
change the screen.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">tag</span>
|
||||
The tag to toggle.
|
||||
</li>
|
||||
<li><span class="parameter">screen</span>
|
||||
<span class="types"><span class="type">number</span></span>
|
||||
The screen to toggle the tag on.
|
||||
(<em>default</em> capi.mouse.screen)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2016-01-03 19:41:48 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,304 @@
|
|||
/* BEGIN RESET
|
||||
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 2.8.2r1
|
||||
*/
|
||||
html {
|
||||
color: #000;
|
||||
background: #FFF;
|
||||
}
|
||||
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
fieldset,img {
|
||||
border: 0;
|
||||
}
|
||||
address,caption,cite,code,dfn,em,strong,th,var,optgroup {
|
||||
font-style: inherit;
|
||||
font-weight: inherit;
|
||||
}
|
||||
del,ins {
|
||||
text-decoration: none;
|
||||
}
|
||||
li {
|
||||
list-style: disc;
|
||||
margin-left: 20px;
|
||||
}
|
||||
caption,th {
|
||||
text-align: left;
|
||||
}
|
||||
h1,h2,h3,h4,h5,h6 {
|
||||
font-size: 100%;
|
||||
font-weight: bold;
|
||||
}
|
||||
q:before,q:after {
|
||||
content: '';
|
||||
}
|
||||
abbr,acronym {
|
||||
border: 0;
|
||||
font-variant: normal;
|
||||
}
|
||||
sup {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
sub {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
legend {
|
||||
color: #000;
|
||||
}
|
||||
input,button,textarea,select,optgroup,option {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
font-style: inherit;
|
||||
font-weight: inherit;
|
||||
}
|
||||
input,button,textarea,select {*font-size:100%;
|
||||
}
|
||||
/* END RESET */
|
||||
|
||||
body {
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
font-family: arial, helvetica, geneva, sans-serif;
|
||||
background-color: #ffffff; margin: 0px;
|
||||
}
|
||||
|
||||
code, tt { font-family: monospace; font-size: 1.1em; }
|
||||
span.parameter { font-family:monospace; }
|
||||
span.parameter:after { content:":"; }
|
||||
span.types:before { content:"("; }
|
||||
span.types:after { content:")"; }
|
||||
.type { font-weight: bold; font-style:italic }
|
||||
|
||||
body, p, td, th { font-size: .95em; line-height: 1.2em;}
|
||||
|
||||
p, ul { margin: 10px 0 0 0px;}
|
||||
|
||||
strong { font-weight: bold;}
|
||||
|
||||
em { font-style: italic;}
|
||||
|
||||
h1 {
|
||||
font-size: 1.5em;
|
||||
margin: 0 0 20px 0;
|
||||
}
|
||||
h2, h3, h4 { margin: 15px 0 10px 0; }
|
||||
h2 { font-size: 1.25em; }
|
||||
h3 { font-size: 1.15em; }
|
||||
h4 { font-size: 1.06em; }
|
||||
|
||||
a:link { font-weight: bold; color: #004080; text-decoration: none; }
|
||||
a:visited { font-weight: bold; color: #006699; text-decoration: none; }
|
||||
a:link:hover { text-decoration: underline; }
|
||||
|
||||
hr {
|
||||
color:#cccccc;
|
||||
background: #00007f;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
blockquote { margin-left: 3em; }
|
||||
|
||||
ul { list-style-type: disc; }
|
||||
|
||||
p.name {
|
||||
font-family: "Andale Mono", monospace;
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: rgb(245, 245, 245);
|
||||
border: 1px solid #C0C0C0; /* silver */
|
||||
padding: 10px;
|
||||
margin: 10px 0 10px 0;
|
||||
overflow: auto;
|
||||
font-family: "Andale Mono", monospace;
|
||||
}
|
||||
|
||||
pre.example {
|
||||
font-size: .85em;
|
||||
}
|
||||
|
||||
table.index { border: 1px #00007f; }
|
||||
table.index td { text-align: left; vertical-align: top; }
|
||||
|
||||
#container {
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
#product {
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #cccccc;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#product big {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#main {
|
||||
background-color: #f0f0f0;
|
||||
border-left: 2px solid #cccccc;
|
||||
}
|
||||
|
||||
#navigation {
|
||||
float: left;
|
||||
width: 14em;
|
||||
vertical-align: top;
|
||||
background-color: #f0f0f0;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
#navigation h2 {
|
||||
background-color:#e7e7e7;
|
||||
font-size:1.1em;
|
||||
color:#000000;
|
||||
text-align: left;
|
||||
padding:0.2em;
|
||||
border-top:1px solid #dddddd;
|
||||
border-bottom:1px solid #dddddd;
|
||||
}
|
||||
|
||||
#navigation ul
|
||||
{
|
||||
font-size:1em;
|
||||
list-style-type: none;
|
||||
margin: 1px 1px 10px 1px;
|
||||
}
|
||||
|
||||
#navigation li {
|
||||
text-indent: -1em;
|
||||
display: block;
|
||||
margin: 3px 0px 0px 22px;
|
||||
}
|
||||
|
||||
#navigation li li a {
|
||||
margin: 0px 3px 0px -1em;
|
||||
}
|
||||
|
||||
#content {
|
||||
margin-left: 14em;
|
||||
padding: 1em;
|
||||
width: 700px;
|
||||
border-left: 2px solid #cccccc;
|
||||
border-right: 2px solid #cccccc;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#about {
|
||||
clear: both;
|
||||
padding: 5px;
|
||||
border-top: 2px solid #cccccc;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
@media print {
|
||||
body {
|
||||
font: 12pt "Times New Roman", "TimeNR", Times, serif;
|
||||
}
|
||||
a { font-weight: bold; color: #004080; text-decoration: underline; }
|
||||
|
||||
#main {
|
||||
background-color: #ffffff;
|
||||
border-left: 0px;
|
||||
}
|
||||
|
||||
#container {
|
||||
margin-left: 2%;
|
||||
margin-right: 2%;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#content {
|
||||
padding: 1em;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#navigation {
|
||||
display: none;
|
||||
}
|
||||
pre.example {
|
||||
font-family: "Andale Mono", monospace;
|
||||
font-size: 10pt;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
}
|
||||
|
||||
table.module_list {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #cccccc;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.module_list td {
|
||||
border-width: 1px;
|
||||
padding: 3px;
|
||||
border-style: solid;
|
||||
border-color: #cccccc;
|
||||
}
|
||||
table.module_list td.name { background-color: #f0f0f0; min-width: 200px; }
|
||||
table.module_list td.summary { width: 100%; }
|
||||
|
||||
|
||||
table.function_list {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #cccccc;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.function_list td {
|
||||
border-width: 1px;
|
||||
padding: 3px;
|
||||
border-style: solid;
|
||||
border-color: #cccccc;
|
||||
}
|
||||
table.function_list td.name { background-color: #f0f0f0; min-width: 200px; }
|
||||
table.function_list td.summary { width: 100%; }
|
||||
|
||||
ul.nowrap {
|
||||
overflow:auto;
|
||||
white-space:nowrap;
|
||||
}
|
||||
|
||||
dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;}
|
||||
dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;}
|
||||
dl.table h3, dl.function h3 {font-size: .95em;}
|
||||
|
||||
/* stop sublists from having initial vertical space */
|
||||
ul ul { margin-top: 0px; }
|
||||
ol ul { margin-top: 0px; }
|
||||
ol ol { margin-top: 0px; }
|
||||
ul ol { margin-top: 0px; }
|
||||
|
||||
/* make the target distinct; helps when we're navigating to a function */
|
||||
a:target + * {
|
||||
background-color: #FF9;
|
||||
}
|
||||
|
||||
|
||||
/* styles for prettification of source */
|
||||
pre .comment { color: #558817; }
|
||||
pre .constant { color: #a8660d; }
|
||||
pre .escape { color: #844631; }
|
||||
pre .keyword { color: #aa5050; font-weight: bold; }
|
||||
pre .library { color: #0e7c6b; }
|
||||
pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
|
||||
pre .string { color: #8080ff; }
|
||||
pre .number { color: #f8660d; }
|
||||
pre .operator { color: #2239a8; font-weight: bold; }
|
||||
pre .preprocessor, pre .prepro { color: #a33243; }
|
||||
pre .global { color: #800080; }
|
||||
pre .user-keyword { color: #800080; }
|
||||
pre .prompt { color: #558817; }
|
||||
pre .url { color: #272fc2; text-decoration: underline; }
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
--- Provides functionality to share tags across all screens in awesome WM.
|
||||
-- @module sharedtags
|
||||
-- @author Albert Diserholt
|
||||
-- @copyright 2016 Albert Diserholt
|
||||
-- @license MIT
|
||||
|
||||
-- Grab environment we need
|
||||
local awful = require("awful")
|
||||
local capi = {
|
||||
tag = tag,
|
||||
screen = screen,
|
||||
mouse = mouse
|
||||
}
|
||||
|
||||
local sharedtags = {
|
||||
_VERSION = "sharedtags v1.0.0",
|
||||
_DESCRIPTION = "Share tags for awesome window manager",
|
||||
_URL = "https://github.com/Drauthius/awesome-sharedtags",
|
||||
_LICENSE = [[
|
||||
MIT LICENSE
|
||||
|
||||
Copyright (c) 2016 Albert Diserholt
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
]]
|
||||
}
|
||||
|
||||
--- Create new tag objects.
|
||||
-- The first tag defined for each screen will be automatically selected.
|
||||
-- @tparam table def A list of tables with the optional keys `name`, `layout`
|
||||
-- and `screen`. The `name` value is used to name the tag and defaults to the
|
||||
-- list index. The `layout` value sets the starting layout for the tag and
|
||||
-- defaults to the first layout. The `screen` value sets the starting screen
|
||||
-- for the tag and defaults to the first screen. The tags will be sorted in this
|
||||
-- order in the default taglist.
|
||||
-- @treturn table A list of all created tags.
|
||||
-- @usage local tags = sharedtags(
|
||||
-- -- "main" is the first tag starting on screen 2 with the tile layout.
|
||||
-- { name = "main", layout = awful.layout.suit.tile, screen = 2 },
|
||||
-- -- "www" is the second tag on screen 1 with the floating layout.
|
||||
-- { name = "www" },
|
||||
-- -- Third tag is named "3" on screen 1 with the floating layout.
|
||||
-- {})
|
||||
function sharedtags.new(def)
|
||||
local tags = {}
|
||||
|
||||
for i,t in ipairs(def) do
|
||||
tags[i] = awful.tag.add(t.name or i, {
|
||||
screen = math.min(capi.screen.count(), t.screen or 1),
|
||||
layout = t.layout,
|
||||
sharedtagindex = i
|
||||
})
|
||||
|
||||
-- If no tag is selected for this screen, then select this one.
|
||||
if not awful.tag.selected(awful.tag.getscreen(tags[i])) then
|
||||
awful.tag.viewonly(tags[i]) -- Updates the history as well.
|
||||
end
|
||||
end
|
||||
|
||||
return tags
|
||||
end
|
||||
|
||||
--- Move the specified tag to a new screen, if necessary.
|
||||
-- @param tag The tag to move.
|
||||
-- @tparam[opt=capi.mouse.screen] number screen The screen to move the tag to.
|
||||
-- @treturn bool Whether the tag was moved.
|
||||
function sharedtags.movetag(tag, screen)
|
||||
screen = screen or capi.mouse.screen
|
||||
local oldscreen = awful.tag.getscreen(tag)
|
||||
|
||||
-- If the specified tag is allocated to another screen, we need to move it.
|
||||
if oldscreen ~= screen then
|
||||
local oldsel = awful.tag.selected(oldscreen)
|
||||
|
||||
-- This works around a bug in the taglist module. It only receives
|
||||
-- signals for when a tag or client changes something. Moving a tag
|
||||
-- with no clients doesn't trigger a signal, and can thus leave the
|
||||
-- taglist outdated. The work around is to hide the tag prior to the
|
||||
-- move, and then restore its hidden status.
|
||||
local hide = awful.tag.getproperty(tag, "hide")
|
||||
awful.tag.setproperty(tag, "hide", true)
|
||||
|
||||
awful.tag.setscreen(tag, screen)
|
||||
|
||||
awful.tag.setproperty(tag, "hide", hide)
|
||||
|
||||
if oldsel == tag then
|
||||
-- The tag has been moved away. In most cases the tag history
|
||||
-- function will find the best match, but if we really want we can
|
||||
-- try to find a fallback tag as well.
|
||||
if not awful.tag.selected(oldscreen) then
|
||||
local newtag = awful.tag.find_fallback(oldscreen)
|
||||
if newtag then
|
||||
awful.tag.viewonly(newtag)
|
||||
else
|
||||
end
|
||||
end
|
||||
else
|
||||
-- A bit of a weird one. Moving a previously selected tag
|
||||
-- deselects the current tag, probably because the history is
|
||||
-- restored to the first entry. Restoring it to the previous entry
|
||||
-- seems to work well enough.
|
||||
awful.tag.history.restore(oldscreen, "previous")
|
||||
end
|
||||
|
||||
-- Also sort the tag in the taglist, by reapplying the index. This is just a nicety.
|
||||
for _,screen in ipairs({ screen, oldscreen }) do
|
||||
for _,t in ipairs(awful.tag.gettags(screen)) do
|
||||
awful.tag.setproperty(t, "index", awful.tag.getproperty(t, "sharedtagindex"))
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
--- View the specified tag on the specified screen.
|
||||
-- @param tag The only tag to view.
|
||||
-- @tparam[opt=capi.mouse.screen] number screen The screen to view the tag on.
|
||||
function sharedtags.viewonly(tag, screen)
|
||||
sharedtags.movetag(tag, screen)
|
||||
awful.tag.viewonly(tag)
|
||||
end
|
||||
|
||||
--- Toggle the specified tag on the specified screen.
|
||||
-- The tag will be selected if the screen changes, and toggled if it does not
|
||||
-- change the screen.
|
||||
-- @param tag The tag to toggle.
|
||||
-- @tparam[opt=capi.mouse.screen] number screen The screen to toggle the tag on.
|
||||
function sharedtags.viewtoggle(tag, screen)
|
||||
local oldscreen = awful.tag.getscreen(tag)
|
||||
|
||||
if sharedtags.movetag(tag, screen) then
|
||||
-- Always mark the tag selected if the screen moved. Just feels a lot
|
||||
-- more natural.
|
||||
tag.selected = true
|
||||
-- Update the history on the old and new screens.
|
||||
capi.screen[oldscreen]:emit_signal("tag::history::update")
|
||||
capi.screen[awful.tag.getscreen(tag)]:emit_signal("tag::history::update")
|
||||
else
|
||||
-- Only toggle the tag unless the screen moved.
|
||||
awful.tag.viewtoggle(tag)
|
||||
end
|
||||
end
|
||||
|
||||
capi.tag.add_signal("property::sharedtagindex")
|
||||
|
||||
return setmetatable(sharedtags, { __call = function(...) return sharedtags.new(select(2, ...)) end })
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
|
@ -0,0 +1,96 @@
|
|||
This patch adds the necessary changes to create and manage tags shareable on
|
||||
all screens when using the awesome window manager.
|
||||
|
||||
The library and all relevant documentation can be found at
|
||||
https://github.com/Drauthius/awesome-sharedtags
|
||||
|
||||
--- orig/rc.lua 2016-01-01 13:45:26.000000000 +0100
|
||||
+++ sharedtags/rc.lua 2016-01-05 20:09:21.428836239 +0100
|
||||
@@ -36,6 +36,11 @@
|
||||
end
|
||||
-- }}}
|
||||
|
||||
+-- {{{ Local extensions
|
||||
+local sharedtags = require("sharedtags")
|
||||
+-- }}}
|
||||
+
|
||||
+
|
||||
-- {{{ Variable definitions
|
||||
-- Themes define colours, icons, font and wallpapers.
|
||||
beautiful.init("/usr/share/awesome/themes/default/theme.lua")
|
||||
@@ -79,12 +84,16 @@
|
||||
-- }}}
|
||||
|
||||
-- {{{ Tags
|
||||
--- Define a tag table which hold all screen tags.
|
||||
-tags = {}
|
||||
-for s = 1, screen.count() do
|
||||
- -- Each screen has its own tag table.
|
||||
- tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
|
||||
-end
|
||||
+-- Define a tag table shared among all screens.
|
||||
+local tags = sharedtags({
|
||||
+ { name = "main", layout = layouts[2] },
|
||||
+ { name = "www", layout = layouts[10] },
|
||||
+ { name = "chat", screen = 2, layout = layouts[1] },
|
||||
+ { name = "game", layout = layouts[1] },
|
||||
+ { layout = layouts[2] },
|
||||
+ { layout = layouts[2] },
|
||||
+ { screen = 2, layout = layouts[2] }
|
||||
+})
|
||||
-- }}}
|
||||
|
||||
-- {{{ Menu
|
||||
@@ -302,26 +311,24 @@
|
||||
-- View tag only.
|
||||
awful.key({ modkey }, "#" .. i + 9,
|
||||
function ()
|
||||
- local screen = mouse.screen
|
||||
- local tag = awful.tag.gettags(screen)[i]
|
||||
+ local tag = tags[i]
|
||||
if tag then
|
||||
- awful.tag.viewonly(tag)
|
||||
+ sharedtags.viewonly(tag)
|
||||
end
|
||||
end),
|
||||
-- Toggle tag.
|
||||
awful.key({ modkey, "Control" }, "#" .. i + 9,
|
||||
function ()
|
||||
- local screen = mouse.screen
|
||||
- local tag = awful.tag.gettags(screen)[i]
|
||||
+ local tag = tags[i]
|
||||
if tag then
|
||||
- awful.tag.viewtoggle(tag)
|
||||
+ sharedtags.viewtoggle(tag)
|
||||
end
|
||||
end),
|
||||
-- Move client to tag.
|
||||
awful.key({ modkey, "Shift" }, "#" .. i + 9,
|
||||
function ()
|
||||
if client.focus then
|
||||
- local tag = awful.tag.gettags(client.focus.screen)[i]
|
||||
+ local tag = tags[i]
|
||||
if tag then
|
||||
awful.client.movetotag(tag)
|
||||
end
|
||||
@@ -331,7 +338,7 @@
|
||||
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
|
||||
function ()
|
||||
if client.focus then
|
||||
- local tag = awful.tag.gettags(client.focus.screen)[i]
|
||||
+ local tag = tags[i]
|
||||
if tag then
|
||||
awful.client.toggletag(tag)
|
||||
end
|
||||
@@ -365,9 +372,9 @@
|
||||
properties = { floating = true } },
|
||||
{ rule = { class = "gimp" },
|
||||
properties = { floating = true } },
|
||||
- -- Set Firefox to always map on tags number 2 of screen 1.
|
||||
+ -- Set Firefox to always map on tag number 2.
|
||||
-- { rule = { class = "Firefox" },
|
||||
- -- properties = { tag = tags[1][2] } },
|
||||
+ -- properties = { tag = tags[2] } },
|
||||
}
|
||||
-- }}}
|
||||
|
Loading…
Reference in New Issue