qtile float centring and tweaks

This commit is contained in:
atagen 2023-10-19 14:29:33 +11:00
parent 79c9f90e53
commit 6cff59b7ef
16 changed files with 776 additions and 164 deletions

View file

@ -5,11 +5,11 @@
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1693611461,
"narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=",
"lastModified": 1696343447,
"narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca",
"rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4",
"type": "github"
},
"original": {
@ -58,25 +58,26 @@
"nixpkgs-lib": "nixpkgs-lib_4"
},
"locked": {
"lastModified": 1693611461,
"narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=",
"lastModified": 1696343447,
"narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca",
"rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4",
"type": "github"
},
"original": {
"id": "flake-parts",
"type": "indirect"
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1695830400,
"narHash": "sha256-gToZXQVr0G/1WriO83olnqrLSHF2Jb8BPcmCt497ro0=",
"lastModified": 1697456312,
"narHash": "sha256-roiSnrqb5r+ehnKCauPLugoU8S36KgmWraHgRqVYndo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8a86b98f0ba1c405358f1b71ff8b5e1d317f5db2",
"rev": "ca012a02bf8327be9e488546faecae5e05d7d749",
"type": "github"
},
"original": {
@ -89,11 +90,11 @@
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1693471703,
"narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=",
"lastModified": 1696019113,
"narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85",
"rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a",
"type": "github"
},
"original": {
@ -143,11 +144,11 @@
"nixpkgs-lib_4": {
"locked": {
"dir": "lib",
"lastModified": 1693471703,
"narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=",
"lastModified": 1696019113,
"narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85",
"rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a",
"type": "github"
},
"original": {
@ -185,7 +186,7 @@
},
"locked": {
"lastModified": 1,
"narHash": "sha256-UWrgMhmt1I9du1arlBji6l0ijm/33L1B7J3mi68n4oc=",
"narHash": "sha256-TohP8yXFcSpQzFL7evx7D1wVqvCEgmF5qtnSdaCqCso=",
"path": "pywlroots",
"type": "path"
},
@ -213,11 +214,11 @@
"qtile-src": {
"flake": false,
"locked": {
"lastModified": 1695927044,
"narHash": "sha256-Z0EpAYJu01lH1BOJXONynGZmSk7nEqmPj15JXflkGaE=",
"lastModified": 1697524288,
"narHash": "sha256-5KUPyCAyev++MWudkrEDMWTgVQTue5IdH9HMnATWuxI=",
"owner": "qtile",
"repo": "qtile",
"rev": "17f20d65920502d9e4920eae50c036984fd49a25",
"rev": "5a1af7fd65b5fb0d4afb97bb82007cf082044d73",
"type": "github"
},
"original": {
@ -232,7 +233,7 @@
"nixpkgs": "nixpkgs",
"pywlroots": "pywlroots",
"qtile-src": "qtile-src",
"scenefx": "scenefx_2"
"smartfloat": "smartfloat"
}
},
"scenefx": {
@ -268,38 +269,21 @@
"type": "github"
}
},
"scenefx-src_2": {
"flake": false,
"locked": {
"lastModified": 1691347738,
"narHash": "sha256-c/zRWz6njC3RsHzIcWpd5m7CXGprrIhKENpaQVH7Owk=",
"owner": "wlrfx",
"repo": "scenefx",
"rev": "b929a2bbadf467864796ad4ec90882ce86cfebff",
"type": "github"
},
"original": {
"owner": "wlrfx",
"repo": "scenefx",
"type": "github"
}
},
"scenefx_2": {
"smartfloat": {
"inputs": {
"flake-parts": "flake-parts_4",
"nixpkgs": [
"nixpkgs"
],
"scenefx-src": "scenefx-src_2"
]
},
"locked": {
"lastModified": 1,
"narHash": "sha256-MjNre2IVsdGHgumTqojSngsCKSZQPcri01ZikXbyTqQ=",
"path": "scenefx",
"narHash": "sha256-hKPB0q1CYMXpH2kvCs8oCmNcRRoOj1JJDECGGY2A1AU=",
"path": "smartfloat",
"type": "path"
},
"original": {
"path": "scenefx",
"path": "smartfloat",
"type": "path"
}
}

View file

@ -14,10 +14,15 @@
inputs.nixpkgs.follows = "nixpkgs";
};
scenefx = {
url = "path:scenefx";
smartfloat = {
url = "path:smartfloat";
inputs.nixpkgs.follows = "nixpkgs";
};
# scenefx = {
# url = "path:scenefx";
# inputs.nixpkgs.follows = "nixpkgs";
# };
};
outputs = inputs @ {
@ -35,9 +40,9 @@
pkgs,
system,
...
}: {
packages.qtile = with pkgs;
with pkgs.python3Packages;
}: rec {
packages.qtile-unwrapped = with pkgs;
with python3Packages;
buildPythonPackage rec {
pname = "qtile";
version = "unstable-${inputs.qtile-src.lastModifiedDate}";
@ -55,6 +60,8 @@
substituteInPlace libqtile/backend/wayland/cffi/build.py \
--replace /usr/include/pixman-1 ${lib.getDev pkgs.pixman}/include \
--replace /usr/include/libdrm ${lib.getDev pkgs.libdrm}/include/libdrm
cp ${inputs'.smartfloat.packages.default} libqtile/layout/smartfloat.py
echo from libqtile.layout.smartfloat import SmartFloat >> libqtile/layout/__init__.py
'';
nativeBuildInputs = [
pkg-config
@ -82,7 +89,7 @@
libdrm
wayland
xorg.xcbutilwm
inputs'.scenefx.packages.default
# inputs'.scenefx.packages.default
(wlroots.overrideAttrs (wf: wp: {
postPatch =
wp.postPatch
@ -97,6 +104,13 @@
];
doCheck = false;
};
packages.qtile = with pkgs;
with python3Packages;
(python3.withPackages (_: [packages.qtile-unwrapped])).overrideAttrs (_: {
inherit (packages.qtile-unwrapped) pname version meta;
name = with packages.qtile-unwrapped; "${pname}-${version}";
passthru.unwrapped = packages.qtile-unwrapped;
});
};
};
}

380
flakes/qtile/smartfloat/flake.lock generated Normal file
View file

@ -0,0 +1,380 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1696343447,
"narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib_2"
},
"locked": {
"lastModified": 1693611461,
"narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_3": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib_3"
},
"locked": {
"lastModified": 1693611461,
"narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_4": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib_4"
},
"locked": {
"lastModified": 1693611461,
"narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca",
"type": "github"
},
"original": {
"id": "flake-parts",
"type": "indirect"
}
},
"flake-parts_5": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib_5"
},
"locked": {
"lastModified": 1693611461,
"narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca",
"type": "github"
},
"original": {
"id": "flake-parts",
"type": "indirect"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1696193975,
"narHash": "sha256-mnQjUcYgp9Guu3RNVAB2Srr1TqKcPpRXmJf4LJk6KRY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fdd898f8f79e8d2f99ed2ab6b3751811ef683242",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1696019113,
"narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib_2": {
"locked": {
"dir": "lib",
"lastModified": 1693471703,
"narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib_3": {
"locked": {
"dir": "lib",
"lastModified": 1693471703,
"narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib_4": {
"locked": {
"dir": "lib",
"lastModified": 1693471703,
"narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib_5": {
"locked": {
"dir": "lib",
"lastModified": 1693471703,
"narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1695830400,
"narHash": "sha256-gToZXQVr0G/1WriO83olnqrLSHF2Jb8BPcmCt497ro0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8a86b98f0ba1c405358f1b71ff8b5e1d317f5db2",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1695830400,
"narHash": "sha256-gToZXQVr0G/1WriO83olnqrLSHF2Jb8BPcmCt497ro0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8a86b98f0ba1c405358f1b71ff8b5e1d317f5db2",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pywlroots": {
"inputs": {
"flake-parts": "flake-parts_3",
"nixpkgs": [
"qtile",
"nixpkgs"
],
"pywlroots-src": "pywlroots-src",
"scenefx": "scenefx"
},
"locked": {
"lastModified": 1,
"narHash": "sha256-UWrgMhmt1I9du1arlBji6l0ijm/33L1B7J3mi68n4oc=",
"path": "pywlroots",
"type": "path"
},
"original": {
"path": "pywlroots",
"type": "path"
}
},
"pywlroots-src": {
"flake": false,
"locked": {
"lastModified": 1694810594,
"narHash": "sha256-TjOYziToYqXbhAK+h/h00/e7oPluDsGaBP3DJ68jPXM=",
"owner": "flacjacket",
"repo": "pywlroots",
"rev": "fca5c8142930ed4a6c23a906e77813207d993480",
"type": "github"
},
"original": {
"owner": "flacjacket",
"repo": "pywlroots",
"type": "github"
}
},
"qtile": {
"inputs": {
"flake-parts": "flake-parts_2",
"nixpkgs": "nixpkgs_2",
"pywlroots": "pywlroots",
"qtile-src": "qtile-src",
"scenefx": "scenefx_2"
},
"locked": {
"lastModified": 1,
"narHash": "sha256-rdGt6waCz54AHCuxudA/tXu+enyPSYu7uQyMsbnpxRg=",
"path": "../",
"type": "path"
},
"original": {
"path": "../",
"type": "path"
}
},
"qtile-src": {
"flake": false,
"locked": {
"lastModified": 1695927044,
"narHash": "sha256-Z0EpAYJu01lH1BOJXONynGZmSk7nEqmPj15JXflkGaE=",
"owner": "qtile",
"repo": "qtile",
"rev": "17f20d65920502d9e4920eae50c036984fd49a25",
"type": "github"
},
"original": {
"owner": "qtile",
"repo": "qtile",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"qtile": "qtile"
}
},
"scenefx": {
"inputs": {
"flake-parts": "flake-parts_4",
"nixpkgs": "nixpkgs_3",
"scenefx-src": "scenefx-src"
},
"locked": {
"lastModified": 1,
"narHash": "sha256-MjNre2IVsdGHgumTqojSngsCKSZQPcri01ZikXbyTqQ=",
"path": "../scenefx",
"type": "path"
},
"original": {
"path": "../scenefx",
"type": "path"
}
},
"scenefx-src": {
"flake": false,
"locked": {
"lastModified": 1691347738,
"narHash": "sha256-c/zRWz6njC3RsHzIcWpd5m7CXGprrIhKENpaQVH7Owk=",
"owner": "wlrfx",
"repo": "scenefx",
"rev": "b929a2bbadf467864796ad4ec90882ce86cfebff",
"type": "github"
},
"original": {
"owner": "wlrfx",
"repo": "scenefx",
"type": "github"
}
},
"scenefx-src_2": {
"flake": false,
"locked": {
"lastModified": 1691347738,
"narHash": "sha256-c/zRWz6njC3RsHzIcWpd5m7CXGprrIhKENpaQVH7Owk=",
"owner": "wlrfx",
"repo": "scenefx",
"rev": "b929a2bbadf467864796ad4ec90882ce86cfebff",
"type": "github"
},
"original": {
"owner": "wlrfx",
"repo": "scenefx",
"type": "github"
}
},
"scenefx_2": {
"inputs": {
"flake-parts": "flake-parts_5",
"nixpkgs": [
"qtile",
"nixpkgs"
],
"scenefx-src": "scenefx-src_2"
},
"locked": {
"lastModified": 1,
"narHash": "sha256-MjNre2IVsdGHgumTqojSngsCKSZQPcri01ZikXbyTqQ=",
"path": "scenefx",
"type": "path"
},
"original": {
"path": "scenefx",
"type": "path"
}
}
},
"root": "root",
"version": 7
}

View file

@ -0,0 +1,35 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
packages.default = with pkgs;
stdenv.mkDerivation rec {
pname = "smartfloat";
version = "0.1.0";
src = builtins.path {
name = "smartfloat";
path = ./smartfloat.py;
sha256 = "62fe831a0e4d2e02fee85928f844992418d1a94a8eacd5336f1e51d4490adb31";
};
unpackPhase = ''
cp $src $out
'';
};
};
};
}

View file

@ -0,0 +1,108 @@
from __future__ import annotations
from typing import TYPE_CHECKING
from libqtile.backend.base import Window
from libqtile.config import ScreenRect
from libqtile.layout.base import Layout
from typing import List
class SmartWindow:
def __init__(self, payload, x: int, y: int, w: int, h: int) -> None:
self.payload = payload
self.x: int = x
self.y: int = y
self.w: int = w
self.h: int = h
def intersect(self, window) -> bool:
return \
abs((self.x + self.w/2) - (window.x + window.w/2)) * 2 \
< (self.w + window.w) and \
abs((self.y + self.h/2) - (window.y + window.h/2)) * 2 \
< (self.h + window.h)
def __repr__(self):
return "<SmartWindow containing" + \
f"{self.payload} at {self.x}, {self.y}, {self.w}, {self.h}>"
class SmartFloat(Layout):
defaults = [
('name', 'SmartFloat', 'Layout name'),
]
def __init__(self, **config) -> None:
Layout.__init__(self, **config)
self.add_defaults(SmartFloat.defaults)
self.windows: List[SmartWindow] = []
self.dims: ScreenRect | None = None
self.focused: Window | None = None
def find_window(self, client: Window) -> SmartWindow | None:
for window in self.windows:
if window.payload == client:
return window
return None
def add_client(self, client: Window) -> None:
self.windows.append(SmartWindow(client, 0, 0, 600, 600))
def remove(self, client: Window) -> None:
window = self.find_window(client)
if window:
self.windows.remove(window)
def configure(self, client: Window, screen_rect: ScreenRect) -> None:
self.dims = screen_rect
window = self.find_window(client)
if not window:
return
if len(self.windows) == 1:
window.x = screen_rect.x + screen_rect.width // 3
window.y = screen_rect.y + screen_rect.height // 3
window.w = screen_rect.width // 2
window.h = screen_rect.height // 2
# else:
# for other_window in self.windows:
# if not other_window == window and window.intersect(other_window):
# diff_x = window.x - other_window.x
# diff_y = window.y - other_window.y
client.place(
window.x,
window.y,
window.w,
window.h,
self.border_width,
getattr(self, "border_" + "focus" if client.has_focus else "normal"),
above=True
)
client.unhide()
@abstract_method
def focus_first(self):
return None
@abstract_method
def focus_last(self):
return None
@abstract_method
def focus_next(self):
return None
@abstract_method
def focus_previous(self):
return None
@abstract_method
def next(self):
return None
@abstract_method
def previous(self):
return None