mirror of
https://github.com/purhan/dotfiles.git
synced 2025-12-26 14:24:58 +08:00
simplify awesome build
This commit is contained in:
parent
619635a632
commit
f7d5657139
25 changed files with 1039 additions and 643 deletions
|
|
@ -1,4 +0,0 @@
|
|||
## Awesome WM Config
|
||||
|
||||
|
||||

|
||||
|
|
@ -18,9 +18,9 @@ return {
|
|||
region_screenshot = '~/.config/awesome/configuration/utils/screenshot -r',
|
||||
delayed_screenshot = '~/.config/awesome/configuration/utils/screenshot --delayed -r',
|
||||
browser = 'env firefox',
|
||||
editor = 'gvim',
|
||||
editor = 'kitty',
|
||||
social = 'env discord',
|
||||
files = 'nautilus',
|
||||
files = 'thunar',
|
||||
power_manager = 'gnome-power-statistics'
|
||||
},
|
||||
-- List of commands to start once on start-up
|
||||
|
|
@ -32,7 +32,7 @@ return {
|
|||
'ibus-daemon --xim --daemonize',
|
||||
'scream-start',
|
||||
'numlockx on',
|
||||
'/usr/lib/xfce-polkit/xfce-polkit & eval $(gnome-keyring-daemon -s --components=pkcs11,secrets,ssh,gpg)', -- credential manager
|
||||
'/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 & eval $(gnome-keyring-daemon -s --components=pkcs11,secrets,ssh,gpg)', -- credential manager
|
||||
'blueman-tray'
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
require('awful.autofocus')
|
||||
local awful = require('awful')
|
||||
local beautiful = require('beautiful')
|
||||
local hotkeys_popup = require('awful.hotkeys_popup').widget
|
||||
local modkey = require('configuration.keys.mod').modKey
|
||||
local altkey = require('configuration.keys.mod').altKey
|
||||
local apps = require('configuration.apps')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local theme = require('theme')
|
||||
|
||||
-- Key bindings
|
||||
local globalKeys = awful.util.table.join( -- Hotkeys
|
||||
|
|
@ -65,18 +62,6 @@ end, {
|
|||
end, {
|
||||
description = 'switch to next window',
|
||||
group = 'client'
|
||||
}), awful.key({modkey}, 'm', function()
|
||||
focus = not _G.client.focus
|
||||
if not focus then
|
||||
_G.client.focus.minimized = true
|
||||
else
|
||||
for _, c in ipairs(mouse.screen.selected_tag:clients()) do
|
||||
c.minimized = false
|
||||
end
|
||||
end
|
||||
end, {
|
||||
description = 'minimize window in focus / unminimize all',
|
||||
group = 'client'
|
||||
}), awful.key({altkey, 'Shift'}, 'Tab', function()
|
||||
awful.client.focus.byidx(-1)
|
||||
if _G.client.focus then
|
||||
|
|
@ -105,16 +90,6 @@ end, {
|
|||
end, {
|
||||
description = 'mark an area and screenshot it to your clipboard',
|
||||
group = 'screenshots (clipboard)'
|
||||
}), awful.key({modkey}, 'c', function()
|
||||
awful.util.spawn(apps.default.editor)
|
||||
end, {
|
||||
description = 'open a text/code editor',
|
||||
group = 'launcher'
|
||||
}), awful.key({modkey}, 'b', function()
|
||||
awful.util.spawn(apps.default.browser)
|
||||
end, {
|
||||
description = 'open a browser',
|
||||
group = 'launcher'
|
||||
}), awful.key({modkey}, 'Return', function()
|
||||
awful.util.spawn_with_shell(apps.default.terminal)
|
||||
end, {
|
||||
|
|
@ -126,19 +101,6 @@ end, {
|
|||
}), awful.key({modkey, 'Control'}, 'q', _G.awesome.quit, {
|
||||
description = 'quit awesome',
|
||||
group = 'awesome'
|
||||
}), awful.key({modkey, 'Shift'}, 'g', function(t)
|
||||
t = t or awful.screen.focused().selected_tag
|
||||
local current_gap = t.gap
|
||||
local new_gap
|
||||
if current_gap == 0 then
|
||||
new_gap = beautiful.gaps
|
||||
else
|
||||
new_gap = 0
|
||||
end
|
||||
t.gap = new_gap
|
||||
end, {
|
||||
description = 'toggle gaps',
|
||||
group = 'awesome'
|
||||
}), awful.key({modkey}, 'p', function()
|
||||
awful.util.spawn_with_shell(apps.default.power_command)
|
||||
end, {
|
||||
|
|
@ -234,26 +196,11 @@ end, {
|
|||
end, {
|
||||
description = 'decrease the number of columns',
|
||||
group = 'layout'
|
||||
}), awful.key({modkey, 'Control'}, 'n', function()
|
||||
local c = awful.client.restore()
|
||||
-- Focus restored client
|
||||
if c then
|
||||
_G.client.focus = c
|
||||
c:raise()
|
||||
end
|
||||
end, {
|
||||
description = 'restore minimized',
|
||||
group = 'client'
|
||||
}), awful.key({modkey}, 'k', function()
|
||||
_G.toggle_splash()
|
||||
end, {
|
||||
description = 'toggle splash terminal',
|
||||
group = 'launcher'
|
||||
}), awful.key({modkey}, 'j', function()
|
||||
_G.toggle_splash_height()
|
||||
end, {
|
||||
description = 'toggle splash terminal height',
|
||||
group = 'launcher'
|
||||
}), awful.key({}, 'XF86MonBrightnessUp', function()
|
||||
awful.spawn('xbacklight -inc 10')
|
||||
end, {
|
||||
|
|
@ -308,17 +255,7 @@ end, {
|
|||
}), awful.key({modkey}, 'o', awful.client.movetoscreen, {
|
||||
description = 'move window to next screen',
|
||||
group = 'client'
|
||||
}), awful.key({modkey}, 'n', function()
|
||||
awful.spawn(awful.screen.focused().selected_tag.defaultApp, {
|
||||
tag = _G.mouse.screen.selected_tag,
|
||||
placement = awful.placement.bottom_right
|
||||
})
|
||||
end, {
|
||||
description = 'open default program for tag/workspace',
|
||||
group = 'tag'
|
||||
}), awful.key({'Control', altkey}, 'space', function()
|
||||
awful.util.spawn_with_shell('vm-attach attach')
|
||||
end))
|
||||
}))
|
||||
|
||||
-- Bind all key numbers to tags.
|
||||
-- Be careful: we use keycodes to make it works on any keyboard layout.
|
||||
|
|
|
|||
|
|
@ -1,148 +0,0 @@
|
|||
/**
|
||||
* User: deadguy
|
||||
* Copyright: deadguy
|
||||
*/
|
||||
|
||||
configuration {
|
||||
display-drun: "Activate";
|
||||
display-run: "Execute";
|
||||
show-icons: true;
|
||||
sidebar-mode: false;
|
||||
}
|
||||
|
||||
* {
|
||||
background-color: rgb(0, 0, 0, 0);
|
||||
text-color: rgb(255, 255, 255);
|
||||
selbg: rgb(255, 255, 255, 0.5);
|
||||
urgbg: rgb(255, 255, 255);
|
||||
actbg: rgb(255, 255, 255, 0.05);
|
||||
winbg: rgb(255, 255, 255);
|
||||
|
||||
selected-normal-foreground: @winbg;
|
||||
normal-foreground: @text-color;
|
||||
selected-normal-background: @actbg;
|
||||
normal-background: @background-color;
|
||||
|
||||
selected-urgent-foreground: @background-color;
|
||||
urgent-foreground: @text-color;
|
||||
selected-urgent-background: @urgbg;
|
||||
urgent-background: @background-color;
|
||||
|
||||
selected-active-foreground: @winbg;
|
||||
active-foreground: @text-color;
|
||||
selected-active-background: @actbg;
|
||||
active-background: @selbg;
|
||||
|
||||
line-margin: 2;
|
||||
line-padding: 2;
|
||||
separator-style: "none";
|
||||
hide-scrollbar: "true";
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
font: "FiraCode Nerd Font Mono Medium 10";
|
||||
}
|
||||
|
||||
window {
|
||||
location: west;
|
||||
anchor: west;
|
||||
x-offset: 0px;
|
||||
height: 100%;
|
||||
width: 30%;
|
||||
padding: 0%;
|
||||
orientation: horizontal;
|
||||
children: [mainbox];
|
||||
background-color: rgb(20, 20, 20, 0.9);
|
||||
}
|
||||
|
||||
mainbox {
|
||||
spacing: 0em;
|
||||
padding: 0px;
|
||||
width: 100%;
|
||||
children: [ inputbar, listview ];
|
||||
expand: true;
|
||||
}
|
||||
|
||||
button { padding: 5px 2px; }
|
||||
|
||||
button selected {
|
||||
background-color: @active-background;
|
||||
text-color: @background-color;
|
||||
}
|
||||
|
||||
inputbar {
|
||||
children: [ entry ];
|
||||
}
|
||||
|
||||
textbox-prompt-colon {
|
||||
text-color: inherit;
|
||||
expand: false;
|
||||
margin: 0 0.3em 0em 0em;
|
||||
}
|
||||
|
||||
listview {
|
||||
spacing: 0em;
|
||||
dynamic: false;
|
||||
cycle: false;
|
||||
}
|
||||
|
||||
element {
|
||||
padding: 16px;
|
||||
border: 0 0 0 0 solid;
|
||||
}
|
||||
|
||||
entry {
|
||||
expand: true;
|
||||
text-color: @normal-foreground;
|
||||
background-color: rgb(0, 0, 0, 0);
|
||||
vertical-align: 1;
|
||||
padding: 12px;
|
||||
font: "FiraCode Nerd Font Mono Bold 18";
|
||||
}
|
||||
|
||||
element normal.normal {
|
||||
background-color: @normal-background;
|
||||
text-color: @normal-foreground;
|
||||
}
|
||||
|
||||
element normal.urgent {
|
||||
background-color: @urgent-background;
|
||||
text-color: @urgent-foreground;
|
||||
}
|
||||
|
||||
element normal.active {
|
||||
background-color: @active-background;
|
||||
text-color: @active-foreground;
|
||||
}
|
||||
|
||||
element selected.normal {
|
||||
background-color: @selected-normal-background;
|
||||
text-color: @selected-normal-foreground;
|
||||
padding: 16px;
|
||||
border: 0 0 0 0 solid;
|
||||
border-color: @active-background;
|
||||
}
|
||||
|
||||
element selected.urgent {
|
||||
background-color: @selected-urgent-background;
|
||||
text-color: @selected-urgent-foreground;
|
||||
}
|
||||
|
||||
element selected.active {
|
||||
background-color: @selected-active-background;
|
||||
text-color: @selected-active-foreground;
|
||||
}
|
||||
|
||||
element alternate.normal {
|
||||
background-color: @normal-background;
|
||||
text-color: @normal-foreground;
|
||||
}
|
||||
|
||||
element alternate.urgent {
|
||||
background-color: @urgent-background;
|
||||
text-color: @urgent-foreground;
|
||||
}
|
||||
|
||||
element alternate.active {
|
||||
background-color: @active-background;
|
||||
text-color: @active-foreground;
|
||||
}
|
||||
|
|
@ -4,23 +4,27 @@ local gears = require('gears')
|
|||
local apps = require('configuration.apps')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
|
||||
local tags = {
|
||||
{text = 'web', type = 'web', defaultApp = apps.default.browser, screen = 1},
|
||||
{text = 'dev', type = 'dev', defaultApp = apps.default.editor, screen = 1},
|
||||
{
|
||||
text = 'term',
|
||||
type = 'term',
|
||||
defaultApp = apps.default.terminal,
|
||||
local tags = {{
|
||||
text = 'web',
|
||||
screen = 1
|
||||
},
|
||||
{text = 'file', type = 'file', defaultApp = apps.default.files, screen = 1},
|
||||
{text = 'chat', type = 'chat', defaultApp = apps.default.social, screen = 1},
|
||||
{text = 'misc', type = 'misc', defaultApp = apps.default.rofi, screen = 1}
|
||||
}
|
||||
}, {
|
||||
text = 'dev',
|
||||
screen = 1
|
||||
}, {
|
||||
text = 'term',
|
||||
screen = 1
|
||||
}, {
|
||||
text = 'file',
|
||||
screen = 1
|
||||
}, {
|
||||
text = 'chat',
|
||||
screen = 1
|
||||
}, {
|
||||
text = 'misc',
|
||||
screen = 1
|
||||
}}
|
||||
|
||||
awful.layout.layouts = {
|
||||
awful.layout.suit.tile, awful.layout.suit.max, awful.layout.suit.floating
|
||||
}
|
||||
awful.layout.layouts = {awful.layout.suit.tile, awful.layout.suit.max, awful.layout.suit.floating}
|
||||
|
||||
awful.screen.connect_for_each_screen(function(s)
|
||||
for i, tag in pairs(tags) do
|
||||
|
|
|
|||
|
|
@ -22,9 +22,6 @@ SILENT=(
|
|||
gnome-clocks
|
||||
)
|
||||
|
||||
#Kill the polkit
|
||||
killall xfce-polkit
|
||||
|
||||
# First kill lingering apps
|
||||
for app in "${APPS[@]}"
|
||||
do
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
local awful = require('awful')
|
||||
local top_bar = require('layout.top-bar')
|
||||
local bottom_bar = require('layout.bottom-bar')
|
||||
|
||||
local key_grabber
|
||||
local beautiful = require('beautiful')
|
||||
|
||||
-- Create a wibox for each screen and add it
|
||||
awful.screen.connect_for_each_screen(function(s)
|
||||
if s.index == 1 then
|
||||
s.top_bar = top_bar(s, true)
|
||||
if not beautiful.title_bar then
|
||||
s.bottom_bar = bottom_bar(s, true)
|
||||
end
|
||||
else
|
||||
s.top_bar = top_bar(s, false)
|
||||
if not beautiful.title_bar then
|
||||
s.bottom_bar = bottom_bar(s, false)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Hide bars when app go fullscreen
|
||||
|
|
@ -21,9 +24,11 @@ function updateBarsVisibility()
|
|||
if s.selected_tag then
|
||||
local fullscreen = s.selected_tag.fullscreenMode
|
||||
s.top_bar.visible = not fullscreen
|
||||
if not beautiful.title_bar then
|
||||
s.bottom_bar.visible = not fullscreen
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
_G.tag.connect_signal('property::selected', function(t)
|
||||
|
|
|
|||
927
src/.config/awesome/module/smart-borders.lua
Normal file
927
src/.config/awesome/module/smart-borders.lua
Normal file
|
|
@ -0,0 +1,927 @@
|
|||
local wibox = require("wibox")
|
||||
local gears = require("gears")
|
||||
local awful = require("awful")
|
||||
local theme = require("beautiful")
|
||||
local naughty = require("naughty")
|
||||
local glib = require("lgi").GLib
|
||||
local dpi = theme.xresources.apply_dpi
|
||||
|
||||
local module = {}
|
||||
|
||||
local client, screen, mouse = client, screen, mouse
|
||||
|
||||
local instances = {}
|
||||
|
||||
local function update_on_signal(c, signal, widget)
|
||||
local sig_instances = instances[signal]
|
||||
if sig_instances == nil then
|
||||
sig_instances = setmetatable({}, {__mode = "k"})
|
||||
instances[signal] = sig_instances
|
||||
client.connect_signal(signal, function(cl)
|
||||
local widgets = sig_instances[cl]
|
||||
if widgets then
|
||||
for _, w in pairs(widgets) do
|
||||
w.update()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
local widgets = sig_instances[c]
|
||||
if widgets == nil then
|
||||
widgets = setmetatable({}, {__mode = "v"})
|
||||
sig_instances[c] = widgets
|
||||
end
|
||||
table.insert(widgets, widget)
|
||||
end
|
||||
|
||||
local glib_context = function(fn)
|
||||
return function(args)
|
||||
glib.idle_add(glib.PRIORITY_DEFAULT_IDLE, function()
|
||||
fn(args)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local function ori(pos)
|
||||
if pos == "left" or pos == "right" then
|
||||
return "v"
|
||||
end
|
||||
return "h"
|
||||
end
|
||||
|
||||
local function list2map(list)
|
||||
local set = {}
|
||||
for _, l in ipairs(list) do
|
||||
set[l] = true
|
||||
end
|
||||
return set
|
||||
end
|
||||
|
||||
local function len(T)
|
||||
local count = 0
|
||||
for _ in pairs(T) do
|
||||
count = count + 1
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
local function doubleclicked(obj)
|
||||
if obj.doubleclick_timer then
|
||||
obj.doubleclick_timer:stop()
|
||||
obj.doubleclick_timer = nil
|
||||
return true
|
||||
end
|
||||
obj.doubleclick_timer = gears.timer.start_new(0.3, function()
|
||||
obj.doubleclick_timer = nil
|
||||
end)
|
||||
return false
|
||||
end
|
||||
|
||||
local menu_selection_symbol
|
||||
local menu_marker = function(condition)
|
||||
if condition then
|
||||
return menu_selection_symbol
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
local menu_move2tag = function(c, scr)
|
||||
local list = {}
|
||||
local s = scr or awful.screen.focused()
|
||||
local count = 0
|
||||
for _, t in pairs(s.tags) do
|
||||
if t ~= awful.screen.focused().selected_tag then
|
||||
count = count + 1
|
||||
local entry = {
|
||||
t.index .. ": " .. t.name .. menu_marker(t.selected) .. " ",
|
||||
function()
|
||||
c:move_to_tag(t)
|
||||
end,
|
||||
}
|
||||
table.insert(list, entry)
|
||||
end
|
||||
end
|
||||
if count > 0 then
|
||||
return list
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local menu_move2screen = function(c)
|
||||
local list = {}
|
||||
local count = 0
|
||||
for s in screen do
|
||||
local desc = next(s.outputs) or ""
|
||||
if s.index ~= awful.screen.focused().index then
|
||||
count = count + 1
|
||||
local entry = {s.index .. ": " .. desc .. " ", menu_move2tag(c, s)}
|
||||
table.insert(list, entry)
|
||||
end
|
||||
end
|
||||
if count > 1 then
|
||||
return list
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function module.menu_client(custom_menu, c)
|
||||
local list = {}
|
||||
|
||||
local list_tags = menu_move2tag(c)
|
||||
if list_tags then
|
||||
table.insert(list, {"move to tag", list_tags})
|
||||
end
|
||||
|
||||
local list_screens = menu_move2screen(c)
|
||||
if list_screens then
|
||||
table.insert(list, {"move to screen", list_screens})
|
||||
end
|
||||
|
||||
table.insert(list, {
|
||||
"fullscreen" .. menu_marker(c.fullscreen),
|
||||
function()
|
||||
c.fullscreen = not c.fullscreen
|
||||
c:raise()
|
||||
end,
|
||||
})
|
||||
|
||||
table.insert(list, {
|
||||
"maximize" .. menu_marker(c.maximized),
|
||||
function()
|
||||
c.maximized = not c.maximized
|
||||
c:raise()
|
||||
end,
|
||||
})
|
||||
|
||||
table.insert(list, {
|
||||
"master" .. menu_marker(c == awful.client.getmaster()),
|
||||
function()
|
||||
c:swap(awful.client.getmaster())
|
||||
end,
|
||||
})
|
||||
|
||||
table.insert(list, {
|
||||
"sticky" .. menu_marker(c.sticky),
|
||||
function()
|
||||
c.sticky = not c.sticky
|
||||
end,
|
||||
})
|
||||
|
||||
table.insert(list, {
|
||||
"top" .. menu_marker(c.ontop),
|
||||
function()
|
||||
c.ontop = not c.ontop
|
||||
end,
|
||||
})
|
||||
|
||||
table.insert(list, {
|
||||
"minimize" .. menu_marker(c.minimized),
|
||||
function()
|
||||
if c.minimized then
|
||||
c.minimized = false
|
||||
c:raise()
|
||||
else
|
||||
c.minimized = true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
table.insert(list, {
|
||||
"floating" .. menu_marker(c.floating),
|
||||
function()
|
||||
c.floating = not c.floating
|
||||
end,
|
||||
})
|
||||
|
||||
table.insert(list, {
|
||||
menu_marker(nil) .. "close",
|
||||
function()
|
||||
c:kill()
|
||||
end,
|
||||
})
|
||||
|
||||
if custom_menu and len(custom_menu) > 0 then
|
||||
local function generate_menu_entry(e)
|
||||
if e and type(e) == 'table' and e.text then
|
||||
local text = ""
|
||||
if type(e.text) == 'string' then
|
||||
text = e.text
|
||||
end
|
||||
if type(e.text) == 'function' then
|
||||
text = e.text(c)
|
||||
end
|
||||
return {
|
||||
text,
|
||||
function()
|
||||
if e.func then
|
||||
e.func(c)
|
||||
end
|
||||
end,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local class = c.class or ""
|
||||
for regex, entries in pairs(custom_menu) do
|
||||
if string.find(class, regex) then
|
||||
for _, e in ipairs(entries) do
|
||||
local menu_entry = generate_menu_entry(e)
|
||||
if menu_entry then
|
||||
table.insert(list, menu_entry)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return list
|
||||
end
|
||||
|
||||
local rounded_corner_shape = function(radius, position)
|
||||
if position == "bottom" then
|
||||
return function(cr, width, height)
|
||||
gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, radius)
|
||||
end
|
||||
elseif position == "top" then
|
||||
return function(cr, width, height)
|
||||
gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, radius)
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local add_hot_corner = function(args)
|
||||
args = args or {}
|
||||
local position = args.position or ""
|
||||
local placement = awful.placement[position]
|
||||
if not placement then
|
||||
return
|
||||
end
|
||||
local actions = args.buttons or {}
|
||||
local s = args.screen or awful.screen.focused()
|
||||
local width = args.width
|
||||
local height = args.height
|
||||
local color = args.color
|
||||
|
||||
local corner = awful.popup({
|
||||
screen = s,
|
||||
placement = placement,
|
||||
ontop = true,
|
||||
border_width = 0,
|
||||
minimum_height = height,
|
||||
maximum_height = height,
|
||||
minimum_width = width,
|
||||
maximum_width = width,
|
||||
bg = color,
|
||||
widget = wibox.widget.background,
|
||||
})
|
||||
|
||||
-- this will run for every screen, so we have to make sure to only add one signal handler for every assigned signal
|
||||
local must_connect_signal = (s.index == 1)
|
||||
|
||||
local function signal_name(pos, action)
|
||||
return "hot_corners::" .. pos .. "::" .. action
|
||||
end
|
||||
|
||||
local defs = {
|
||||
{name = "left_click", button = 1},
|
||||
{name = "middle_click", button = 2},
|
||||
{name = "right_click", button = 3},
|
||||
{name = "wheel_up", button = 4},
|
||||
{name = "wheel_down", button = 5},
|
||||
{name = "back_click", button = 8},
|
||||
{name = "forward_click", button = 9},
|
||||
}
|
||||
|
||||
local buttons = {}
|
||||
for _, btn in ipairs(defs) do
|
||||
if actions[btn.name] then
|
||||
local signal = signal_name(position, btn.name)
|
||||
table.insert(buttons, awful.button({}, btn.button, function()
|
||||
awesome.emit_signal(signal)
|
||||
end))
|
||||
if must_connect_signal then
|
||||
awesome.connect_signal(signal, glib_context(actions[btn.name]))
|
||||
end
|
||||
end
|
||||
end
|
||||
corner:buttons(buttons)
|
||||
|
||||
for _, action in pairs({"enter", "leave"}) do
|
||||
if actions[action] then
|
||||
local signal = signal_name(position, action)
|
||||
corner:connect_signal("mouse::" .. action, function()
|
||||
awesome.emit_signal(signal)
|
||||
end)
|
||||
if must_connect_signal then
|
||||
awesome.connect_signal(signal, glib_context(actions[action]))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function new(config)
|
||||
local cfg = config or {}
|
||||
local positions = cfg.positions or {"left", "right", "top", "bottom"}
|
||||
local button_positions = cfg.button_positions or {"top"}
|
||||
local border_width = cfg.border_width or dpi(6)
|
||||
local rounded_corner = cfg.rounded_corner or nil
|
||||
|
||||
local color_normal = cfg.color_normal or "#56666f"
|
||||
local color_focus = cfg.color_focus or "#a1bfcf"
|
||||
local color_hover = cfg.color_hover or nil
|
||||
local color_floating = cfg.color_floating or nil
|
||||
local color_maximized = cfg.color_maximized or nil
|
||||
|
||||
local button_size = cfg.button_size or dpi(40)
|
||||
local spacing_widget = cfg.spacing_widget or nil
|
||||
|
||||
local button_maximize_size = cfg.button_maximize_size or button_size
|
||||
local button_minimize_size = cfg.button_minimize_size or button_size
|
||||
local button_floating_size = cfg.button_floating_size or button_size
|
||||
local button_top_size = cfg.button_top_size or button_size
|
||||
local button_sticky_size = cfg.button_sticky_size or button_size
|
||||
local button_close_size = cfg.button_close_size or button_size
|
||||
|
||||
local color_maximize_normal = cfg.color_maximize_normal or "#a9dd9d"
|
||||
local color_maximize_focus = cfg.color_maximize_focus or "#a9dd9d"
|
||||
local color_maximize_hover = cfg.color_maximize_hover or "#c3f7b7"
|
||||
|
||||
local color_minimize_normal = cfg.color_minimize_normal or "#f0eaaa"
|
||||
local color_minimize_focus = cfg.color_minimize_focus or "#f0eaaa"
|
||||
local color_minimize_hover = cfg.color_minimize_hover or "#f6ffea"
|
||||
|
||||
local color_close_normal = cfg.color_close_normal or "#fd8489"
|
||||
local color_close_focus = cfg.color_close_focus or "#fd8489"
|
||||
local color_close_hover = cfg.color_close_hover or "#ff9ea3"
|
||||
|
||||
local color_floating_normal = cfg.color_floating_normal or "#ddace7"
|
||||
local color_floating_focus = cfg.color_floating_focus or "#ddace7"
|
||||
local color_floating_hover = cfg.color_floating_hover or "#f7c6ff"
|
||||
|
||||
local color_sticky_normal = cfg.color_sticky_normal or "#fb8965"
|
||||
local color_sticky_focus = cfg.color_sticky_focus or "#fb8965"
|
||||
local color_sticky_hover = cfg.color_sticky_hover or "#ffa37f"
|
||||
|
||||
local color_top_normal = cfg.color_top_normal or "#7fc1ca"
|
||||
local color_top_focus = cfg.color_top_focus or "#7fc1ca"
|
||||
local color_top_hover = cfg.color_top_hover or "#99dbe4"
|
||||
|
||||
local stealth = cfg.stealth or false
|
||||
|
||||
local snapping = cfg.snapping or false
|
||||
local snapping_center_mouse = cfg.snapping_center_mouse or false
|
||||
local snapping_max_distance = cfg.snapping_max_distance or nil
|
||||
|
||||
local hot_corners = cfg.hot_corners or {}
|
||||
local hot_corners_color = cfg.hot_corners_color or "#00000000"
|
||||
local hot_corners_width = cfg.hot_corners_width or dpi(1)
|
||||
local hot_corners_height = cfg.hot_corners_height or dpi(1)
|
||||
|
||||
local show_button_tooltips = cfg.show_button_tooltips or false -- tooltip might intercept mouseclicks; not recommended!
|
||||
local show_title_tooltip = cfg.show_title_tooltip or false -- might fuck up sloppy mouse focus; not recommended!
|
||||
|
||||
local custom_menu_entries = cfg.custom_menu_entries or {}
|
||||
menu_selection_symbol = cfg.menu_selection_symbol or " ✔"
|
||||
|
||||
local layout = cfg.layout or "fixed" -- "fixed" | "ratio"
|
||||
local button_ratio = cfg.button_ratio or 0.2
|
||||
|
||||
local align_horizontal = cfg.align_horizontal or "right" -- "left" | "center" | "right"
|
||||
local align_vertical = cfg.align_vertical or "center" -- "top" | "center" | "bottom"
|
||||
local buttons = cfg.buttons or {"floating", "minimize", "maximize", "close"}
|
||||
|
||||
local button_left_click = cfg.button_left_click or function(c)
|
||||
if c.maximized then
|
||||
c.maximized = false
|
||||
end
|
||||
c:emit_signal("request::activate", "mouse_click", {raise = true})
|
||||
awful.mouse.client.move(c)
|
||||
end
|
||||
local button_double_click = cfg.button_double_click or function(c)
|
||||
c.maximized = not c.maximized
|
||||
end
|
||||
local button_middle_click = cfg.middle_click or function(c)
|
||||
c:emit_signal("request::activate", "mouse_click", {raise = true})
|
||||
awful.mouse.client.resize(c)
|
||||
end
|
||||
local button_right_click = cfg.right_click or function(c)
|
||||
if c.client_menu then
|
||||
c.client_menu:hide()
|
||||
end
|
||||
c.client_menu = awful.menu(module.menu_client(custom_menu_entries, c))
|
||||
c.client_menu:toggle()
|
||||
end
|
||||
|
||||
local resize_factor = cfg.resize_factor or 0.01
|
||||
local button_wheel_up = cfg.button_wheel_up or function(_)
|
||||
awful.client.incwfact(resize_factor)
|
||||
end
|
||||
local button_wheel_down = cfg.button_wheel_down or function(_)
|
||||
awful.client.incwfact(-1 * resize_factor)
|
||||
end
|
||||
local button_back = cfg.button_back or function(_)
|
||||
awful.client.swap.byidx(-1)
|
||||
end
|
||||
local button_forward = cfg.button_forward or function(_)
|
||||
awful.client.swap.byidx(1)
|
||||
end
|
||||
|
||||
local button_funcs = {}
|
||||
|
||||
local left_click_function = function(c)
|
||||
if doubleclicked(c) then
|
||||
button_double_click(c)
|
||||
else
|
||||
button_left_click(c)
|
||||
end
|
||||
end
|
||||
|
||||
client.connect_signal("smart_borders::left_click", left_click_function)
|
||||
client.connect_signal("smart_borders::middle_click", button_middle_click)
|
||||
client.connect_signal("smart_borders::right_click", button_right_click)
|
||||
client.connect_signal("smart_borders::wheel_up", button_wheel_up)
|
||||
client.connect_signal("smart_borders::wheel_down", button_wheel_down)
|
||||
client.connect_signal("smart_borders::back_click", button_back)
|
||||
client.connect_signal("smart_borders::forward_click", button_forward)
|
||||
|
||||
button_funcs[1] = function(c)
|
||||
c:emit_signal("smart_borders::left_click")
|
||||
end
|
||||
|
||||
button_funcs[2] = function(c)
|
||||
c:emit_signal("smart_borders::middle_click")
|
||||
end
|
||||
button_funcs[3] = function(c)
|
||||
c:emit_signal("smart_borders::right_click")
|
||||
end
|
||||
button_funcs[4] = function(c)
|
||||
c:emit_signal("smart_borders::wheel_up")
|
||||
end
|
||||
button_funcs[5] = function(c)
|
||||
c:emit_signal("smart_borders::wheel_down")
|
||||
end
|
||||
button_funcs[8] = function(c)
|
||||
c:emit_signal("smart_borders::back_click")
|
||||
end
|
||||
button_funcs[9] = function(c)
|
||||
c:emit_signal("smart_borders::forward_click")
|
||||
end
|
||||
local function handle_button_press(c, button)
|
||||
local func = button_funcs[button]
|
||||
if func then
|
||||
func(c)
|
||||
end
|
||||
end
|
||||
|
||||
local button_definitions = {}
|
||||
button_definitions["maximize"] = {
|
||||
name = "maximize",
|
||||
color_normal = color_maximize_normal,
|
||||
color_focus = color_maximize_focus,
|
||||
color_hover = color_maximize_hover,
|
||||
button_size = button_maximize_size,
|
||||
action = function(cl)
|
||||
cl.maximized = not cl.maximized
|
||||
end,
|
||||
}
|
||||
|
||||
button_definitions["minimize"] = {
|
||||
name = "minimize",
|
||||
color_normal = color_minimize_normal,
|
||||
color_focus = color_minimize_focus,
|
||||
color_hover = color_minimize_hover,
|
||||
button_size = button_minimize_size,
|
||||
action = function(cl)
|
||||
-- for whatever reason setting minimized does not work without wrapping it.
|
||||
awful.spawn.easy_async_with_shell("sleep 0", function()
|
||||
cl.minimized = true
|
||||
end)
|
||||
end,
|
||||
}
|
||||
|
||||
button_definitions["floating"] = {
|
||||
name = "floating",
|
||||
color_normal = color_floating_normal,
|
||||
color_focus = color_floating_focus,
|
||||
color_hover = color_floating_hover,
|
||||
button_size = button_floating_size,
|
||||
action = function(cl)
|
||||
cl.floating = not cl.floating
|
||||
end,
|
||||
}
|
||||
|
||||
button_definitions["close"] = {
|
||||
name = "close",
|
||||
color_normal = color_close_normal,
|
||||
color_focus = color_close_focus,
|
||||
color_hover = color_close_hover,
|
||||
button_size = button_close_size,
|
||||
action = function(cl)
|
||||
cl:kill()
|
||||
end,
|
||||
}
|
||||
|
||||
button_definitions["sticky"] = {
|
||||
name = "sticky",
|
||||
color_normal = color_sticky_normal,
|
||||
color_focus = color_sticky_focus,
|
||||
color_hover = color_sticky_hover,
|
||||
button_size = button_sticky_size,
|
||||
action = function(cl)
|
||||
cl.sticky = not cl.sticky
|
||||
end,
|
||||
}
|
||||
|
||||
button_definitions["top"] = {
|
||||
name = "top",
|
||||
color_normal = color_top_normal,
|
||||
color_focus = color_top_focus,
|
||||
color_hover = color_top_hover,
|
||||
button_size = button_top_size,
|
||||
action = function(cl)
|
||||
cl.ontop = not cl.ontop
|
||||
end,
|
||||
}
|
||||
|
||||
for s in screen do
|
||||
for pos, buttons in pairs(hot_corners) do
|
||||
add_hot_corner({
|
||||
buttons = buttons,
|
||||
screen = s,
|
||||
position = pos,
|
||||
color = hot_corners_color,
|
||||
width = hot_corners_width,
|
||||
height = hot_corners_height,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
if layout ~= "fixed" and layout ~= "ratio" then
|
||||
layout = "fixed"
|
||||
end
|
||||
|
||||
if type(button_positions) == "string" then
|
||||
button_positions = {button_positions}
|
||||
end
|
||||
|
||||
if snapping then
|
||||
if awful and awful.mouse and awful.mouse.append_global_mousebindings then
|
||||
local mouse_closest_client = function()
|
||||
local s = awful.screen.focused()
|
||||
local m_x = mouse.coords().x
|
||||
local m_y = mouse.coords().y
|
||||
|
||||
local closest_distance, closest_c
|
||||
|
||||
for _, c in ipairs(s.all_clients) do
|
||||
if c:isvisible() then
|
||||
local x = c.x + (c.width / 2)
|
||||
local y = c.y + (c.height / 2)
|
||||
local dx = math.max(math.abs(m_x - x) - (c.width / 2), 0)
|
||||
local dy = math.max(math.abs(m_y - y) - (c.height / 2), 0)
|
||||
local distance = math.sqrt(dx * dx + dy * dy)
|
||||
|
||||
if (not snapping_max_distance or (distance <= snapping_max_distance)) and
|
||||
(not closest_distance or distance < closest_distance) then
|
||||
closest_distance = distance
|
||||
closest_c = c
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if closest_c and closest_c.valid then
|
||||
closest_c:emit_signal("request::activate", "smart_borders::snapping", {raise = true})
|
||||
end
|
||||
|
||||
return closest_c
|
||||
end
|
||||
|
||||
awful.mouse.append_global_mousebindings({
|
||||
awful.button({}, 1, function()
|
||||
local c = mouse_closest_client()
|
||||
if c then
|
||||
if snapping_center_mouse then
|
||||
mouse.coords {x = c.x + c.width / 2, y = c.y + c.height / 2}
|
||||
end
|
||||
left_click_function(c)
|
||||
end
|
||||
end),
|
||||
awful.button({}, 2, function()
|
||||
local c = mouse_closest_client()
|
||||
if c then
|
||||
button_middle_click(c)
|
||||
end
|
||||
end),
|
||||
awful.button({}, 3, function()
|
||||
local c = mouse_closest_client()
|
||||
if c then
|
||||
button_right_click(c)
|
||||
end
|
||||
end),
|
||||
awful.button({}, 4, function()
|
||||
local c = mouse_closest_client()
|
||||
if c then
|
||||
button_wheel_up(c)
|
||||
end
|
||||
end),
|
||||
awful.button({}, 5, function()
|
||||
local c = mouse_closest_client()
|
||||
if c then
|
||||
button_wheel_down(c)
|
||||
end
|
||||
end),
|
||||
awful.button({}, 8, function()
|
||||
local c = mouse_closest_client()
|
||||
if c then
|
||||
button_back(c)
|
||||
end
|
||||
end),
|
||||
awful.button({}, 9, function()
|
||||
local c = mouse_closest_client()
|
||||
if c then
|
||||
button_forward(c)
|
||||
end
|
||||
end),
|
||||
})
|
||||
else
|
||||
naughty.notify({title = "smart_borders", text = "snapping requires awesomewm git version!", timeout = 0})
|
||||
end
|
||||
end
|
||||
|
||||
local smart_border_titlebars = function(c)
|
||||
local button_widgets = {}
|
||||
|
||||
local border_bg = wibox.widget.base.make_widget_declarative(
|
||||
{
|
||||
{widget = wibox.container.margin},
|
||||
id = "border_bg",
|
||||
bg = color_normal,
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
|
||||
border_bg:connect_signal("button::press", function(_, _, _, button)
|
||||
handle_button_press(c, button)
|
||||
end)
|
||||
|
||||
if color_hover then
|
||||
border_bg:connect_signal("mouse::enter", function()
|
||||
border_bg.bg = color_hover
|
||||
end)
|
||||
border_bg:connect_signal("mouse::leave", function()
|
||||
if client.focus == c then
|
||||
border_bg.bg = color_focus
|
||||
else
|
||||
border_bg.bg = color_normal
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local border_expander, border_expander_center
|
||||
|
||||
if layout == "fixed" then
|
||||
border_expander_center = wibox.widget.base.make_widget_declarative(
|
||||
{
|
||||
fill_vertical = true,
|
||||
fill_horizontal = true,
|
||||
content_fill_vertical = true,
|
||||
content_fill_horizontal = true,
|
||||
border_bg,
|
||||
widget = wibox.container.place,
|
||||
})
|
||||
border_expander = wibox.widget.base.make_widget_declarative(
|
||||
{
|
||||
{layout = wibox.layout.fixed.horizontal},
|
||||
border_bg,
|
||||
{layout = wibox.layout.fixed.horizontal},
|
||||
widget = wibox.layout.align.horizontal,
|
||||
})
|
||||
end
|
||||
|
||||
local _button_positions = list2map(button_positions)
|
||||
|
||||
for _, pos in pairs(positions) do
|
||||
local tb = awful.titlebar(c, {size = border_width, position = pos, bg = "#00000000"})
|
||||
|
||||
local btn_layout
|
||||
if layout == "fixed" then
|
||||
btn_layout = ori(pos) == "v" and wibox.layout.fixed.vertical or wibox.layout.fixed.horizontal
|
||||
end
|
||||
if layout == "ratio" then
|
||||
btn_layout = ori(pos) == "v" and wibox.layout.ratio.vertical or wibox.layout.ratio.horizontal
|
||||
end
|
||||
|
||||
if _button_positions[pos] then
|
||||
-- border with buttons
|
||||
local button_layout = wibox.widget.base.make_widget_declarative(
|
||||
{id = "button_layout", spacing_widget = spacing_widget, layout = btn_layout})
|
||||
|
||||
local titlebar_widget
|
||||
|
||||
if layout == "fixed" then
|
||||
if ori(pos) == "v" then
|
||||
local expander = align_vertical == "center" and border_expander_center or border_expander
|
||||
titlebar_widget = wibox.widget.base.make_widget_declarative(
|
||||
{
|
||||
align_vertical == "top" and button_layout or expander,
|
||||
align_vertical == "center" and button_layout or expander,
|
||||
align_vertical == "bottom" and button_layout or expander,
|
||||
expand = align_vertical == "center" and "none" or "inside",
|
||||
layout = wibox.layout.align.vertical,
|
||||
})
|
||||
else
|
||||
local expander = align_horizontal == "center" and border_expander_center or border_expander
|
||||
titlebar_widget = wibox.widget.base.make_widget_declarative(
|
||||
{
|
||||
align_horizontal == "left" and button_layout or expander,
|
||||
align_horizontal == "center" and button_layout or expander,
|
||||
align_horizontal == "right" and button_layout or expander,
|
||||
expand = align_horizontal == "center" and "none" or "inside",
|
||||
layout = wibox.layout.align.horizontal,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
if layout == "ratio" then
|
||||
titlebar_widget = wibox.widget.base.make_widget_declarative(
|
||||
{button_layout, id = "titlebar_widget", bg = color_normal, widget = wibox.container.background})
|
||||
end
|
||||
|
||||
tb:setup{
|
||||
titlebar_widget,
|
||||
bg = "#00000000",
|
||||
shape = rounded_corner and rounded_corner_shape(rounded_corner, pos) or nil,
|
||||
widget = wibox.container.background(),
|
||||
}
|
||||
|
||||
local ratio_button_layout = wibox.widget.base.make_widget_declarative(
|
||||
{
|
||||
homogeneous = layout == "ratio" and true or false,
|
||||
expand = true,
|
||||
layout = ori(pos) == "h" and wibox.layout.grid.horizontal or wibox.layout.grid.vertical,
|
||||
})
|
||||
|
||||
local list_of_buttons = {}
|
||||
for _, btn in pairs(buttons) do
|
||||
local b = button_definitions[btn]
|
||||
|
||||
if not b then
|
||||
-- custom button
|
||||
b = {}
|
||||
b.name = cfg["button_" .. btn .. "_name"] or btn
|
||||
b.button_size = cfg["button_" .. btn .. "_size"] or button_size
|
||||
b.color_focus = cfg["color_" .. btn .. "_focus"] or "#ff00ff"
|
||||
b.color_normal = cfg["color_" .. btn .. "_normal"] or "#ff00ff"
|
||||
b.color_hover = cfg["color_" .. btn .. "_hover"] or "#ff1aff"
|
||||
b.action = cfg["button_" .. btn .. "_function"] or nil
|
||||
end
|
||||
|
||||
local button_widget = wibox.widget.base.make_widget_declarative(
|
||||
{
|
||||
{widget = wibox.container.margin},
|
||||
id = b.name,
|
||||
forced_width = ori(pos) == "h" and b.button_size or nil,
|
||||
forced_height = ori(pos) == "v" and b.button_size or nil,
|
||||
bg = b.color_normal,
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
|
||||
if show_button_tooltips then
|
||||
awful.tooltip {
|
||||
objects = {button_widget},
|
||||
mode = 'outside',
|
||||
timer_function = function()
|
||||
return b.name
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
button_widget:connect_signal("mouse::enter", function()
|
||||
button_widget.bg = b.color_hover
|
||||
end)
|
||||
|
||||
button_widget:connect_signal("mouse::leave", function()
|
||||
if stealth then
|
||||
if c == client.focus then
|
||||
button_widget.bg = color_focus
|
||||
else
|
||||
button_widget.bg = color_normal
|
||||
end
|
||||
else
|
||||
if c == client.focus then
|
||||
button_widget.bg = b.color_focus
|
||||
else
|
||||
button_widget.bg = b.color_normal
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
button_widget:connect_signal("button::press", function(_, _, _, button)
|
||||
if button == 1 then
|
||||
if b.action then
|
||||
b.action(c)
|
||||
end
|
||||
else
|
||||
handle_button_press(c, button)
|
||||
end
|
||||
end)
|
||||
|
||||
table.insert(list_of_buttons, button_widget)
|
||||
|
||||
button_widgets[b.name] = button_widget
|
||||
|
||||
local update = function()
|
||||
if client.focus == c then
|
||||
button_widget.bg = stealth and color_focus or b.color_focus
|
||||
return
|
||||
end
|
||||
button_widget.bg = stealth and color_normal or b.color_normal
|
||||
end
|
||||
|
||||
button_widget.update = update
|
||||
|
||||
update_on_signal(c, "focus", button_widget)
|
||||
update_on_signal(c, "unfocus", button_widget)
|
||||
end
|
||||
|
||||
if layout == "ratio" then
|
||||
ratio_button_layout:set_children(list_of_buttons)
|
||||
local ratio_children = {}
|
||||
table.insert(ratio_children, border_bg)
|
||||
table.insert(ratio_children, ratio_button_layout)
|
||||
table.insert(ratio_children, border_bg)
|
||||
button_layout:set_children(ratio_children)
|
||||
|
||||
if (ori(pos) == "h" and align_horizontal == "left") or (ori(pos) == "v" and align_vertical == "top") then
|
||||
button_layout:ajust_ratio(2, 0, button_ratio, 1.0 - button_ratio)
|
||||
end
|
||||
if (ori(pos) == "h" and align_horizontal == "right") or
|
||||
(ori(pos) == "v" and align_vertical == "bottom") then
|
||||
button_layout:ajust_ratio(2, 1.0 - button_ratio, button_ratio, 0)
|
||||
end
|
||||
if (ori(pos) == "h" and align_horizontal == "center") or
|
||||
(ori(pos) == "v" and align_vertical == "center") then
|
||||
local side_ratio = (1.0 - button_ratio) / 2
|
||||
button_layout:ajust_ratio(2, side_ratio, button_ratio, side_ratio)
|
||||
end
|
||||
end
|
||||
|
||||
if layout == "fixed" then
|
||||
button_layout:set_children(list_of_buttons)
|
||||
end
|
||||
else
|
||||
tb:setup{
|
||||
border_bg,
|
||||
bg = "#00000000",
|
||||
shape = rounded_corner and rounded_corner_shape(rounded_corner, pos) or nil,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- show client title tooltip on border hover
|
||||
if show_title_tooltip then
|
||||
awful.tooltip {
|
||||
objects = {border_bg},
|
||||
timer_function = function()
|
||||
return c.name
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
local update_border = function()
|
||||
if client.focus == c then
|
||||
border_bg.bg = color_focus
|
||||
return
|
||||
end
|
||||
|
||||
if color_maximized and c.maximized then
|
||||
border_bg.bg = color_maximized
|
||||
return
|
||||
end
|
||||
|
||||
if color_floating and c.floating then
|
||||
border_bg.bg = color_floating
|
||||
return
|
||||
end
|
||||
|
||||
border_bg.bg = color_normal
|
||||
end
|
||||
|
||||
border_bg.update = update_border
|
||||
|
||||
update_on_signal(c, "focus", border_bg)
|
||||
update_on_signal(c, "unfocus", border_bg)
|
||||
update_on_signal(c, "property::maximized", border_bg)
|
||||
update_on_signal(c, "property::floating", border_bg)
|
||||
end
|
||||
|
||||
client.connect_signal("request::tag", smart_border_titlebars)
|
||||
end
|
||||
|
||||
return setmetatable(module, {
|
||||
__call = function(_, ...)
|
||||
new(...)
|
||||
return module
|
||||
end,
|
||||
})
|
||||
|
|
@ -2,6 +2,7 @@ require('awful.autofocus')
|
|||
local gears = require('gears')
|
||||
local awful = require('awful')
|
||||
local naughty = require('naughty')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local beautiful = require('beautiful')
|
||||
|
||||
-- Theme
|
||||
|
|
@ -36,27 +37,36 @@ _G.client.connect_signal('manage', function(c)
|
|||
end)
|
||||
|
||||
-- Move cursor to focused window
|
||||
function move_mouse_onto_focused_client()
|
||||
local c = client.focus
|
||||
gears.timer( { timeout = 0.1,
|
||||
function Move_mouse_onto_focused_client()
|
||||
local c = _G.client.focus
|
||||
gears.timer({
|
||||
timeout = 0.1,
|
||||
autostart = true,
|
||||
single_shot = true,
|
||||
callback = function()
|
||||
if mouse.object_under_pointer() ~= c then
|
||||
if _G.mouse.object_under_pointer() ~= c then
|
||||
local geometry = c:geometry()
|
||||
local x = geometry.x + geometry.width/2
|
||||
local y = geometry.y + geometry.height/2
|
||||
mouse.coords({x = x, y = y}, true)
|
||||
local x = geometry.x + geometry.width / 2
|
||||
local y = geometry.y + geometry.height / 2
|
||||
_G.mouse.coords({
|
||||
x = x,
|
||||
y = y
|
||||
}, true)
|
||||
end
|
||||
end } )
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
client.connect_signal("focus", move_mouse_onto_focused_client)
|
||||
client.connect_signal("swapped", move_mouse_onto_focused_client)
|
||||
if beautiful.cursor_warp then
|
||||
_G.client.connect_signal("focus", Move_mouse_onto_focused_client)
|
||||
_G.client.connect_signal("swapped", Move_mouse_onto_focused_client)
|
||||
end
|
||||
|
||||
-- Enable sloppy focus, so that focus follows mouse.
|
||||
_G.client.connect_signal('mouse::enter', function(c)
|
||||
c:emit_signal('request::activate', 'mouse_enter', {raise = true})
|
||||
c:emit_signal('request::activate', 'mouse_enter', {
|
||||
raise = true
|
||||
})
|
||||
end)
|
||||
|
||||
-- Make the focused window have a glowing border
|
||||
|
|
@ -67,3 +77,16 @@ _G.client.connect_signal('unfocus', function(c)
|
|||
c.border_color = beautiful.border_normal
|
||||
end)
|
||||
|
||||
if beautiful.title_bar then
|
||||
-- Enable smart borders (https://github.com/intrntbrn/smart_borders)
|
||||
require('module.smart-borders') {
|
||||
show_button_tooltips = true,
|
||||
border_width = dpi(16),
|
||||
rounded_corner = dpi(0),
|
||||
positions = {"bottom"},
|
||||
button_positions = {"bottom"},
|
||||
button_size = dpi(40),
|
||||
color_focus = beautiful.primary.hue_200,
|
||||
color_normal = beautiful.primary.hue_100
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ local awesome_overrides = function(theme)
|
|||
|
||||
-- Tasklist
|
||||
theme.tasklist_font = theme.font
|
||||
theme.tasklist_bg_normal = theme.primary.hue_200
|
||||
theme.tasklist_bg_focus = theme.primary.hue_100
|
||||
theme.tasklist_bg_normal = theme.primary.hue_100
|
||||
theme.tasklist_bg_focus = theme.primary.hue_200
|
||||
theme.tasklist_bg_urgent = theme.primary.hue_200
|
||||
|
||||
-- Icons
|
||||
|
|
@ -49,5 +49,7 @@ local awesome_overrides = function(theme)
|
|||
theme.border_normal = theme.primary.hue_100
|
||||
theme.gap_single_client = false
|
||||
theme.bg_normal = theme.primary.hue_100
|
||||
theme.cursor_warp = true
|
||||
theme.title_bar = false
|
||||
end
|
||||
return {theme = theme, awesome_overrides = awesome_overrides}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# Colors are different than original, just to match my taste :P
|
||||
|
||||
foreground #d6d6d6
|
||||
background #282828
|
||||
background #282827
|
||||
|
||||
# black
|
||||
color0 #282828
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ hi Normal ctermbg=230
|
|||
set updatetime=100
|
||||
set mouse=a
|
||||
set noswapfile
|
||||
set colorcolumn=80
|
||||
set colorcolumn=90
|
||||
|
||||
"" Set smart line numbers
|
||||
set number relativenumber
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/bash
|
||||
compton &
|
||||
nitrogen --restore &
|
||||
nm-applet &
|
||||
|
||||
|
|
@ -1,289 +0,0 @@
|
|||
import os
|
||||
import subprocess
|
||||
|
||||
from typing import List
|
||||
|
||||
from libqtile import bar, layout, widget, hook
|
||||
from libqtile.config import Click, Drag, Group, Key, Screen, ScratchPad, DropDown
|
||||
from libqtile.lazy import lazy
|
||||
from libqtile.utils import guess_terminal
|
||||
|
||||
mod = "mod4"
|
||||
terminal = "kitty"
|
||||
rofi = """
|
||||
env /usr/bin/rofi -show drun -display-drun -run-command
|
||||
"/bin/bash -c -i 'shopt -s expand_aliases; {cmd}'"
|
||||
"""
|
||||
config_directory = os.path.expanduser("~/.config/qtile")
|
||||
|
||||
BLACK = "#212121"
|
||||
LIGHT_GREY = "#3c3c3c"
|
||||
GREY = "#333333"
|
||||
DARK_GREY = "#1a1a1a"
|
||||
YELLOW = "#e1be7f"
|
||||
GREEN = "#92c96a"
|
||||
BLUE = "#66aeea"
|
||||
RED = "#f35a5a"
|
||||
CYAN = "#4083bc"
|
||||
MAGENTA = "#c57cda"
|
||||
ORANGE = "#cd996a"
|
||||
WHITE = "#d6d6d6"
|
||||
|
||||
keys = [
|
||||
# Switch between windows in current stack pane
|
||||
Key([mod], "k", lazy.layout.down(), desc="Move focus down in stack pane"),
|
||||
Key([mod], "j", lazy.layout.up(), desc="Move focus up in stack pane"),
|
||||
# Move windows up or down in current stack
|
||||
Key(
|
||||
[mod, "control"],
|
||||
"k",
|
||||
lazy.layout.shuffle_down(),
|
||||
desc="Move window down in current stack ",
|
||||
),
|
||||
Key(
|
||||
[mod, "control"],
|
||||
"j",
|
||||
lazy.layout.shuffle_up(),
|
||||
desc="Move window up in current stack ",
|
||||
),
|
||||
Key(["mod1"], "Tab", lazy.layout.next(), desc="Move focus to next window in group"),
|
||||
Key(
|
||||
["mod1", "shift"],
|
||||
"Tab",
|
||||
lazy.layout.previous(),
|
||||
desc="Move focus to previous window in group",
|
||||
),
|
||||
# Toggle between split and unsplit sides of stack.
|
||||
# Split = all windows displayed
|
||||
# Unsplit = 1 window displayed, like Max layout, but still with
|
||||
# multiple stack panes
|
||||
Key(
|
||||
[mod, "shift"],
|
||||
"Return",
|
||||
lazy.layout.toggle_split(),
|
||||
desc="Toggle between split and unsplit sides of stack",
|
||||
),
|
||||
Key([mod], "Return", lazy.spawn(terminal), desc="Launch terminal"),
|
||||
# Toggle between different layouts as defined below
|
||||
Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"),
|
||||
Key([mod, "shift"], "q", lazy.window.kill(), desc="Kill focused window"),
|
||||
Key([mod, "shift"], "c", lazy.window.kill(), desc="Kill focused window"),
|
||||
Key([mod, "control"], "r", lazy.restart(), desc="Restart qtile"),
|
||||
Key([mod, "control"], "q", lazy.shutdown(), desc="Shutdown qtile"),
|
||||
Key([mod], "r", lazy.spawn(rofi), desc="Launch Rofi"),
|
||||
Key(
|
||||
[mod],
|
||||
"p",
|
||||
lazy.spawn(f"{config_directory}/src/rofi-power.sh"),
|
||||
desc="Launch rofi power options",
|
||||
),
|
||||
# Volume Control
|
||||
Key([], "XF86AudioRaiseVolume", lazy.spawn("amixer -c 0 -q set Master 2dB+")),
|
||||
Key([], "XF86AudioLowerVolume", lazy.spawn("amixer -c 0 -q set Master 2dB-")),
|
||||
Key([], "XF86AudioMute", lazy.spawn("amixer -D pulse set Master 1+ toggle")),
|
||||
Key([mod], "equal", lazy.spawn("amixer -c 0 -q set Master 2dB+")),
|
||||
Key([mod], "minus", lazy.spawn("amixer -c 0 -q set Master 2dB-")),
|
||||
# Window management
|
||||
Key([mod], "h", lazy.layout.shrink_main(), desc="Expand master (MonadTall)"),
|
||||
Key([mod], "l", lazy.layout.grow_main(), desc="Shrink master (MonadTall)"),
|
||||
Key(
|
||||
[mod, "shift"],
|
||||
"h",
|
||||
lazy.layout.swap_left(),
|
||||
desc="Move window to left (MonadTall)",
|
||||
),
|
||||
Key(
|
||||
[mod, "shift"],
|
||||
"l",
|
||||
lazy.layout.swap_right(),
|
||||
desc="Moce window to right (MonadTall)",
|
||||
),
|
||||
Key([mod], "k", lazy.group["scratchpad"].dropdown_toggle("dropdown_terminal")),
|
||||
Key([mod], "Left", lazy.screen.prev_group(skip_managed=True)),
|
||||
Key([mod], "Right", lazy.screen.next_group(skip_managed=True)),
|
||||
]
|
||||
|
||||
group_names = (
|
||||
("web", {"layout": "max"}),
|
||||
("dev", {"layout": "monadtall"}),
|
||||
("term", {"layout": "monadtall"}),
|
||||
("file", {"layout": "monadtall"}),
|
||||
("chat", {"layout": "monadtall"}),
|
||||
("misc", {"layout": "monadtall"}),
|
||||
)
|
||||
|
||||
groups = [Group(name, **kwargs) for name, kwargs in group_names]
|
||||
|
||||
# Create a dropdown terminal
|
||||
groups.append(
|
||||
ScratchPad(
|
||||
"scratchpad",
|
||||
[
|
||||
DropDown(
|
||||
"dropdown_terminal",
|
||||
f"{terminal} -T dropdown_terminal",
|
||||
on_focus_lost_hide=False,
|
||||
opacity=1,
|
||||
width=0.999,
|
||||
x=0.0005,
|
||||
height=0.55,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
for i, (name, kwargs) in enumerate(group_names, 1):
|
||||
# Switch to another group
|
||||
keys.append(Key([mod], str(i), lazy.group[name].toscreen(toggle=False)))
|
||||
# Switch to last group
|
||||
keys.append(Key([mod], "Escape", lazy.screen.toggle_group()))
|
||||
# Send window to group
|
||||
keys.append(Key([mod, "shift"], str(i), lazy.window.togroup(name)))
|
||||
|
||||
layout_theme = {
|
||||
"border_width": 2,
|
||||
"margin": 0,
|
||||
"single_border_width": 0,
|
||||
"border_focus": GREEN,
|
||||
"border_normal": BLACK,
|
||||
}
|
||||
|
||||
layouts = [
|
||||
layout.Max(**layout_theme),
|
||||
# layout.Stack(**layout_theme, num_stacks=2),
|
||||
# Try more layouts by unleashing below layouts.
|
||||
# layout.Bsp(**layout_theme),
|
||||
# layout.Columns(**layout_theme),
|
||||
# layout.Matrix(**layout_theme),
|
||||
layout.MonadTall(**layout_theme),
|
||||
# layout.MonadWide(**layout_theme),
|
||||
# layout.RatioTile(**layout_theme),
|
||||
# layout.Tile(**layout_theme),
|
||||
# layout.TreeTab(**layout_theme),
|
||||
# layout.VerticalTile(**layout_theme),
|
||||
# layout.Zoomy(**layout_theme),
|
||||
layout.Floating(
|
||||
**layout_theme,
|
||||
float_rules=[
|
||||
# Run the utility of `xprop` to see the wm class and name of an X client.
|
||||
{"wmclass": "confirm"},
|
||||
{"wmclass": "dialog"},
|
||||
{"wmclass": "download"},
|
||||
{"wmclass": "error"},
|
||||
{"wmclass": "file_progress"},
|
||||
{"wmclass": "notification"},
|
||||
{"wmclass": "splash"},
|
||||
{"wmclass": "toolbar"},
|
||||
{"wmclass": "confirmreset"}, # gitk
|
||||
{"wmclass": "makebranch"}, # gitk
|
||||
{"wmclass": "maketag"}, # gitk
|
||||
{"wname": "branchdialog"}, # gitk
|
||||
{"wname": "pinentry"}, # GPG key password entry
|
||||
{"wmclass": "ssh-askpass"}, # ssh-askpass
|
||||
],
|
||||
),
|
||||
]
|
||||
|
||||
widget_defaults = dict(
|
||||
font="Ubuntu",
|
||||
fontsize=12,
|
||||
padding=3,
|
||||
)
|
||||
extension_defaults = widget_defaults.copy()
|
||||
|
||||
screens = [
|
||||
Screen(
|
||||
top=bar.Bar(
|
||||
[
|
||||
widget.GroupBox(
|
||||
margin_y=3,
|
||||
margin_x=0,
|
||||
padding_y=5,
|
||||
padding_x=3,
|
||||
disable_drag=True,
|
||||
active=BLUE,
|
||||
inactive=WHITE,
|
||||
rounded=False,
|
||||
highlight_color=BLUE,
|
||||
highlight_method="block",
|
||||
this_current_screen_border=BLUE,
|
||||
this_screen_border=GREEN,
|
||||
block_highlight_text_color=BLACK,
|
||||
other_current_screen_border=GREEN,
|
||||
other_screen_border=BLACK,
|
||||
urgent_alert_method="text",
|
||||
urgent_text=RED,
|
||||
),
|
||||
widget.Prompt(),
|
||||
widget.Spacer(),
|
||||
widget.Systray(),
|
||||
widget.Clock(format="%m/%d %a %I:%M"),
|
||||
widget.Sep(),
|
||||
widget.CPU(format=" {load_percent}%"),
|
||||
widget.Sep(),
|
||||
widget.Memory(),
|
||||
widget.Volume(),
|
||||
widget.Battery(format="{char} {percent:2.0%}", notify_below=20),
|
||||
widget.CurrentLayoutIcon(scale=0.65),
|
||||
],
|
||||
20,
|
||||
),
|
||||
bottom=bar.Bar(
|
||||
[
|
||||
widget.TaskList(
|
||||
borderwidth=0,
|
||||
spacing=0,
|
||||
highlight_method="block",
|
||||
background=GREY,
|
||||
border=BLACK,
|
||||
markup_floating="<i>{}</i>",
|
||||
markup_minimized="<s>{}</s>",
|
||||
icon_size=0,
|
||||
margin=0,
|
||||
rounded=False,
|
||||
title_width_method="uniform",
|
||||
),
|
||||
],
|
||||
18,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
# Drag floating layouts.
|
||||
mouse = [
|
||||
Drag(
|
||||
[mod],
|
||||
"Button1",
|
||||
lazy.window.set_position_floating(),
|
||||
start=lazy.window.get_position(),
|
||||
),
|
||||
Drag(
|
||||
[mod], "Button3", lazy.window.set_size_floating(), start=lazy.window.get_size()
|
||||
),
|
||||
Click([mod], "Button2", lazy.window.toggle_floating()),
|
||||
]
|
||||
|
||||
dgroups_key_binder = None
|
||||
dgroups_app_rules = [] # type: List
|
||||
main = None # WARNING: this is deprecated and will be removed soon
|
||||
follow_mouse_focus = True
|
||||
bring_front_click = False
|
||||
cursor_warp = False
|
||||
auto_fullscreen = True
|
||||
focus_on_window_activation = "smart"
|
||||
|
||||
|
||||
@hook.subscribe.startup
|
||||
def autostart():
|
||||
subprocess.call([f"{config_directory}/autostart.sh"])
|
||||
|
||||
|
||||
# XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
|
||||
# string besides java UI toolkits; you can see several discussions on the
|
||||
# mailing lists, GitHub issues, and other WM documentation that suggest setting
|
||||
# this string if your java app doesn't work correctly. We may as well just lie
|
||||
# and say that we're a working one by default.
|
||||
#
|
||||
# We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in
|
||||
# java that happens to be on java's whitelist.
|
||||
wmname = "LG3D"
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
qtile==0.16.2.dev209+gd5848931
|
||||
psutil==5.8.0
|
||||
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# rofi-power
|
||||
# Use rofi to call systemctl for shutdown, reboot, etc
|
||||
|
||||
# 2016 Oliver Kraitschy - http://okraits.de
|
||||
|
||||
OPTIONS="Poweroff\nExit\nReboot\nSuspend\nHibernate"
|
||||
|
||||
config_path=$(dirname "$0")
|
||||
|
||||
LAUNCHER="rofi -dmenu -i"
|
||||
USE_LOCKER="false"
|
||||
LOCKER="i3lock-fancy"
|
||||
|
||||
option=`echo -e $OPTIONS | $LAUNCHER | awk '{print $1}' | tr -d '\r\n'`
|
||||
case $option in
|
||||
Exit)
|
||||
kill -9 -1
|
||||
;;
|
||||
Reboot)
|
||||
systemctl reboot
|
||||
;;
|
||||
Poweroff)
|
||||
systemctl poweroff
|
||||
;;
|
||||
Suspend)
|
||||
$($USE_LOCKER) && "$LOCKER"; systemctl suspend
|
||||
;;
|
||||
Hibernate)
|
||||
$($USE_LOCKER) && "$LOCKER"; systemctl hibernate
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
"auto_close": false,
|
||||
"timeit": true,
|
||||
|
||||
"post_window_hooks": [["carry_file_to_pane", { "direction": "down" }]],
|
||||
"post_window_hooks": [["carry_file_to_pane", { "direction": "right" }]],
|
||||
|
||||
"focus": false,
|
||||
"cmd": [
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"autoformat_on_save": "true",
|
||||
}
|
||||
|
|
@ -1,27 +1,27 @@
|
|||
{
|
||||
"name": "Terminus",
|
||||
"variables": {
|
||||
"blue": "#01a0e4",
|
||||
"light_green": "#3a3432",
|
||||
"light_brown": "#4a4543",
|
||||
"green": "#01a252",
|
||||
"light_blue": "#807d7c",
|
||||
"cyan": "#b5e4f4",
|
||||
"light_red": "#e8bbd0",
|
||||
"black": "#090300",
|
||||
"light_white": "#f7f7f8",
|
||||
"magenta": "#a16a94",
|
||||
"background": "#f7f7f8",
|
||||
"light_cyan": "#cdab53",
|
||||
"caret": "#4a4543",
|
||||
"brown": "#fded02",
|
||||
"white": "#a5a2a2",
|
||||
"light_black": "#5c5855",
|
||||
"light_magenta": "#d6d5d4",
|
||||
"red": "#db2d20",
|
||||
"foreground": "#4a4543"
|
||||
},
|
||||
"globals": {
|
||||
"background": "#f7f7f7"
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"white": "#a5a2a2",
|
||||
"blue": "#01a0e4",
|
||||
"light_brown": "#4a4543",
|
||||
"light_red": "#e8bbd0",
|
||||
"magenta": "#a16a94",
|
||||
"light_white": "#f7f7f8",
|
||||
"green": "#01a252",
|
||||
"light_magenta": "#d6d5d4",
|
||||
"background": "#f7f7f8",
|
||||
"light_black": "#5c5855",
|
||||
"foreground": "#4a4543",
|
||||
"red": "#db2d20",
|
||||
"light_green": "#3a3432",
|
||||
"cyan": "#b5e4f4",
|
||||
"black": "#090300",
|
||||
"brown": "#fded02",
|
||||
"light_cyan": "#cdab53",
|
||||
"caret": "#4a4543",
|
||||
"light_blue": "#807d7c"
|
||||
},
|
||||
"name": "Terminus"
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
.PHONY: all
|
||||
all: autosuggestions syntax-highlighting tab-completions
|
||||
all: autosuggestions syntax-highlighting tab-completions z-jump
|
||||
|
||||
autosuggestions:
|
||||
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.config/zsh/plugins/zsh-autosuggestions
|
||||
|
|
|
|||
|
|
@ -25,7 +25,3 @@
|
|||
[credential "https://github.com"]
|
||||
helper = !gh auth git-credential
|
||||
|
||||
; global hooks
|
||||
[core]
|
||||
hooksPath = /home/purhan/scripts/hooks/git/
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ xinput set-prop "ETPS/2 Elantech Touchpad" "libinput Tapping Enabled" 1
|
|||
# Turn off laptop screen when monitor connected
|
||||
hdmi_connected=$(xrandr | grep ' connected' | grep 'HDMI' | wc -l)
|
||||
if [ "$hdmi_connected" -eq 1 ]; then
|
||||
eval "~/scripts/monitor_setups/monitor_only"
|
||||
eval "~/scripts/monitor_setups/laptop_left_primary_monitor_right"
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ apt = firefox \
|
|||
vim \
|
||||
neovim \
|
||||
awesome \
|
||||
i3lock-fancy \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
npm \
|
||||
|
|
@ -25,6 +26,8 @@ apt = firefox \
|
|||
zsh \
|
||||
stow \
|
||||
arandr \
|
||||
xdotool \
|
||||
polkit-gnome-authentication-agent-1 \
|
||||
gh
|
||||
|
||||
# Packages to be installed as snaps
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
|
||||
protected_branches="main master dev"
|
||||
|
||||
if [[ "$protected_branches" == *"$current_branch"* ]];
|
||||
then
|
||||
read -p "You're about to push master, is that what you intended? [y|N] " -n 1 -r < /dev/tty
|
||||
echo
|
||||
if echo $REPLY | grep -E '^[Yy]$' > /dev/null
|
||||
then
|
||||
exit 0 # push will execute
|
||||
fi
|
||||
exit 1 # push will not execute
|
||||
else
|
||||
exit 0 # push will execute
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue