Fix dotfiles structure
This commit is contained in:
1
.config/awesome/awesome-scratch/.gitignore
vendored
Executable file
1
.config/awesome/awesome-scratch/.gitignore
vendored
Executable file
@@ -0,0 +1 @@
|
||||
*~
|
||||
27
.config/awesome/awesome-scratch/README.md
Executable file
27
.config/awesome/awesome-scratch/README.md
Executable file
@@ -0,0 +1,27 @@
|
||||
awesome-scratch
|
||||
===============
|
||||
|
||||
scratchpad windows (similar to a quake console) for awesome wm
|
||||
|
||||
###Usage
|
||||
`scratch.toggle` is used to show and hide scratch windows. It takes a shell command to launch the scratch window and a rule to match the scratch window.
|
||||
|
||||
for example using ezconfig we can add bindings for a scratch terminal and a scratch python repl:
|
||||
```
|
||||
local launchprogs = ezconfig.keytable.join({
|
||||
-- scratchpad programs
|
||||
['M-c'] = { scratch.toggle, "urxvt -name scratch-term"
|
||||
, { instance = "scratch-term" } }
|
||||
, ['M-S-p'] = { scratch.toggle, "urxvt -name scratch-python -e python"
|
||||
, { instance = "scratch-python" } }
|
||||
...
|
||||
```
|
||||
|
||||
You'll also probably want to add a rule to make the scratch windows float:
|
||||
```
|
||||
awful.rules.rules = {
|
||||
...
|
||||
{ rule = { instance = "scratch" },
|
||||
properties = { floating = true} },
|
||||
}
|
||||
```
|
||||
60
.config/awesome/awesome-scratch/scratch.lua
Executable file
60
.config/awesome/awesome-scratch/scratch.lua
Executable file
@@ -0,0 +1,60 @@
|
||||
local client = client
|
||||
local awful = require("awful")
|
||||
local util = require("awful.util")
|
||||
|
||||
local scratch = {}
|
||||
local defaultRule = {instance = "scratch"}
|
||||
|
||||
-- Turn on this scratch window client (add current tag to window's tags,
|
||||
-- then set focus to the window)
|
||||
local function turn_on(c)
|
||||
local current_tag = awful.tag.selected(c.screen)
|
||||
ctags = {current_tag}
|
||||
for k,tag in pairs(c:tags()) do
|
||||
if tag ~= current_tag then table.insert(ctags, tag) end
|
||||
end
|
||||
c:tags(ctags)
|
||||
c:raise()
|
||||
client.focus = c
|
||||
end
|
||||
|
||||
-- Turn off this scratch window client (remove current tag from window's tags)
|
||||
local function turn_off(c)
|
||||
local current_tag = awful.tag.selected(c.screen)
|
||||
local ctags = {}
|
||||
for k,tag in pairs(c:tags()) do
|
||||
if tag ~= current_tag then table.insert(ctags, tag) end
|
||||
end
|
||||
c:tags(ctags)
|
||||
end
|
||||
|
||||
function scratch.raise(cmd, rule)
|
||||
local rule = rule or defaultRule
|
||||
local function matcher(c) return awful.rules.match(c, rule) end
|
||||
|
||||
-- logic mostly copied form awful.client.run_or_raise, except we don't want
|
||||
-- to change to or merge with scratchpad tag, just show the window
|
||||
local clients = client.get()
|
||||
local findex = util.table.hasitem(clients, client.focus) or 1
|
||||
local start = util.cycle(#clients, findex + 1)
|
||||
|
||||
for c in awful.client.iterate(matcher, start) do
|
||||
turn_on(c)
|
||||
return
|
||||
end
|
||||
|
||||
-- client not found, spawn it
|
||||
util.spawn(cmd)
|
||||
end
|
||||
|
||||
function scratch.toggle(cmd, rule, alwaysclose)
|
||||
local rule = rule or defaultRule
|
||||
|
||||
if client.focus and awful.rules.match(client.focus, rule) then
|
||||
turn_off(client.focus)
|
||||
else
|
||||
scratch.raise(cmd, rule)
|
||||
end
|
||||
end
|
||||
|
||||
return scratch
|
||||
Reference in New Issue
Block a user