-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added sharedtags-greedyview to recipes #126
Open
dakling
wants to merge
9
commits into
awesomeWM:master
Choose a base branch
from
dakling:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ff131e4
Create sharedtags-greedyview
dakling 39ca703
Rename sharedtags-greedyview to sharedtags-greedyview.mdwn
dakling a75f74f
Create sharedtags-greedyview.lua
dakling 4a48891
Added sharedtags recipe
dakling 2e66eb2
Update sharedtags-greedyview.mdwn
dakling 08e119c
Update recipes.mdwn
dakling 30a0ebd
Update sharedtags-greedyview.lua
dakling 7642c0c
implemented suggestions
dakling d4a396a
improved swapping behaviour
dakling File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# Helper for multiple monitors (based on xrandr) | ||
|
||
The [[sharedtags-greedyview.lua|sharedtags-greedyview.lua]] script implements the xmonad default | ||
behaviour in which tags are handled for multiple monitors, namely: | ||
* A list of tags is shared between all screens | ||
* Selecting a tag shows it on the screen that is focused, regardless of the previous screen of the tag (greedyview) | ||
* If the selected tag was already visible on the other screen, swap tags between screens | ||
|
||
# Credit | ||
|
||
I forked the script from https://github.com/Elv13/awesome-sharedtags and only added a few lines to implement the | ||
swapping behaviour described above. | ||
|
||
# Setup | ||
|
||
The process of setting up this script is as follows: | ||
|
||
1. Create a file called `sharedtags-greedyview.lua` in your file system (preferably in | ||
awesome's folder) with the [[script|xrandr.lua]] content. | ||
|
||
2. Import the script in your `rc.lua` | ||
|
||
```lua | ||
local sharedtags = require("sharedtags-greedyview") | ||
``` | ||
|
||
3. Create the tags using the `sharedtags()` method, instead of the original | ||
ones created with `awful.tag()`. They should be created at the file level, | ||
i.e. outside of any function. | ||
|
||
```lua | ||
local tags = sharedtags({ | ||
{ name = "main", layout = awful.layout.layouts[2] }, | ||
{ name = "www", layout = awful.layout.layouts[10] }, | ||
{ name = "game", layout = awful.layout.layouts[1] }, | ||
{ name = "misc", layout = awful.layout.layouts[2] }, | ||
{ name = "chat", screen = 2, layout = awful.layout.layouts[2] }, | ||
{ layout = awful.layout.layouts[2] }, | ||
{ screen = 2, layout = awful.layout.layouts[2] } | ||
}) | ||
``` | ||
4. Remove or uncomment the code which creates the tags when a screen is | ||
connected, in the `connect_for_each_screen` callback. | ||
|
||
```lua | ||
awful.screen.connect_for_each_screen(function(s) | ||
-- Each screen has its own tag table. | ||
--awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) | ||
|
||
-- Here is a good place to add tags to a newly connected screen, if desired: | ||
--sharedtags.viewonly(tags[4], s) | ||
end) | ||
``` | ||
5. The code for handling tags and clients needs to be changed to use the | ||
library and pick the correct tag. | ||
|
||
```lua | ||
for i = 1, 9 do | ||
globalkeys = gears.table.join(globalkeys, | ||
-- View tag only. | ||
awful.key({ modkey }, "#" .. i + 9, | ||
function () | ||
local screen = awful.screen.focused() | ||
local tag = tags[i] | ||
if tag then | ||
sharedtags.viewonly(tag, screen) | ||
end | ||
end, | ||
{description = "view tag #"..i, group = "tag"}), | ||
-- Toggle tag display. | ||
awful.key({ modkey, "Control" }, "#" .. i + 9, | ||
function () | ||
local screen = awful.screen.focused() | ||
local tag = tags[i] | ||
if tag then | ||
sharedtags.viewtoggle(tag, screen) | ||
end | ||
end, | ||
{description = "toggle tag #" .. i, group = "tag"}), | ||
-- Move client to tag. | ||
awful.key({ modkey, "Shift" }, "#" .. i + 9, | ||
function () | ||
if client.focus then | ||
local tag = tags[i] | ||
if tag then | ||
client.focus:move_to_tag(tag) | ||
end | ||
end | ||
end, | ||
{description = "move focused client to tag #"..i, group = "tag"}), | ||
-- Toggle tag on focused client. | ||
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, | ||
function () | ||
if client.focus then | ||
local tag = tags[i] | ||
if tag then | ||
client.focus:toggle_tag(tag) | ||
end | ||
end | ||
end, | ||
{description = "toggle focused client on tag #" .. i, group = "tag"}) | ||
) | ||
end | ||
``` | ||
6. Lastly, any rules referencing the screen and tag should use the newly | ||
created `tags` array instead. | ||
|
||
```lua | ||
awful.rules.rules = { | ||
-- Set Firefox to always map on tag number 2. | ||
{ rule = { class = "Firefox" }, | ||
properties = { tag = tags[2] } }, -- or tags["www"] to map it to the name instead | ||
} | ||
``` | ||
7. Restart or reload *awesome*. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
xrandr.lua
?