diff --git a/CMakeLists.txt b/CMakeLists.txt index 93c90fe..9ea3295 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ set(POSITION_INDEPENDENT_CODE YES) set(C_STANDARD 11) add_compile_options(-Wall -Wextra) -pkg_check_modules(CONSTRAIN REQUIRED x11 xi xfixes xrandr) +pkg_check_modules(CONSTRAIN REQUIRED luajit x11 xi xfixes xrandr) add_library(constrain SHARED lib/constrain.c) target_link_libraries(constrain ${CONSTRAIN_LIBRARIES}) target_include_directories(constrain PUBLIC ${CONSTRAIN_INCLUDE_DIRS}) diff --git a/Makefile b/Makefile index 28d9d58..b2fbd47 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,12 @@ LUA_FILES = $(shell find src -type f -name '*.lua') rc.lua settings.lua test: build { sleep 1; DISPLAY=:10 awesome -c "$(CURDIR)/rc.lua"; } & Xephyr :10 -name xephyr_awesome -ac -br -noreset -screen "1920x1080" +.PHONY: testv +testv: build + { sleep 1; DISPLAY=:10 awesome -c "$(CURDIR)/rc.lua"; } & \ + { sleep 2; DISPLAY=:10 st & DISPLAY=:10 st & DISPLAY=:10 st & DISPLAY=:10 st & DISPLAY=:10 st; } & \ + Xephyr :10 -name xephyr_awesome -ac -br -noreset -screen "1080x1920" + .PHONY: deploy deploy: build rsync -avmh --delete --exclude 'settings.lua' --include '*.lua' --include '*.so' --include '*.png' --include '*/' --include '*.rasi' --include '*.sh' --exclude '*' ./ ~/.config/awesome/ diff --git a/awesome.code-workspace b/awesome.code-workspace index ea8dc7f..e33388e 100644 --- a/awesome.code-workspace +++ b/awesome.code-workspace @@ -1,9 +1,11 @@ { "folders": [ { + "name": "awesome (dev)", "path": "." }, { + "name": "awesome (.config)", "path": "../../.config/awesome" } ], @@ -27,4 +29,4 @@ "/home/mutzi/.config/awesome" ] } -} \ No newline at end of file +} diff --git a/icons/fairc.png b/icons/fairc.png new file mode 100755 index 0000000..f354fbb Binary files /dev/null and b/icons/fairc.png differ diff --git a/settings.lua b/settings.lua index 604a226..3a5204d 100644 --- a/settings.lua +++ b/settings.lua @@ -1,5 +1,6 @@ return { wallpaper = 'wall2.png', + vallpaper = 'vall0.png', systray_screen = 1, show_battery = false diff --git a/src/global_keys.lua b/src/global_keys.lua index 5727a31..88dbd65 100644 --- a/src/global_keys.lua +++ b/src/global_keys.lua @@ -85,10 +85,13 @@ local globalkeys = gears.table.join( awful.key({ modkey, altkey }, 'Return', function() quake:toggle() end, { description = 'Dropdown terminal', group = 'programs' }), awful.key({ modkey }, 'y', function() awful.spawn('rofi -show drun -theme "' .. os.getenv('HOME') .. '/.config/awesome/rofi/launcher.rasi"') - end, { description = 'show rofi', group = 'launcher' }), + end, { description = 'show drun', group = 'launcher' }), + awful.key({ modkey, 'Control', 'Shift' }, 'y', function() + awful.spawn('rofi -show drun -drun-show-actions -theme "' .. os.getenv('HOME') .. '/.config/awesome/rofi/launcher.rasi"') + end, { description = 'show drun actions', group = 'launcher' }), awful.key({ modkey, 'Shift' }, 'y', function() awful.spawn(os.getenv('HOME') .. '/.config/awesome/rofi/launcher_launcher.sh') - end, { description = 'show rofi', group = 'launcher' }), + end, { description = 'show rofi launcher', group = 'launcher' }), ---- LAYOUT ---- awful.key({ modkey, altkey }, 'l', function() awful.tag.incmwfact(0.05) end, { description = 'increase master width factor', group = 'layout' }), diff --git a/src/layouts/fair_col.lua b/src/layouts/fair_col.lua new file mode 100644 index 0000000..76dda23 --- /dev/null +++ b/src/layouts/fair_col.lua @@ -0,0 +1,35 @@ +local ipairs = ipairs +local math = math + +local fair = {} +fair.name = "fairc" + +function fair.arrange(s) + local wa = s.workarea + local cls = s.clients + + if #cls > 0 then + local clc = #cls + local row_h = math.ceil(wa.height / clc) + clc = clc - 1 + + for i, c in ipairs(cls) do + i = i - 1 + local g = { + width=wa.width, + x=wa.x + } + if i == clc then + g.height = wa.height - row_h * i + g.y = wa.y + wa.height - g.height + else + g.height = row_h + g.y = wa.y + row_h * i + end + + s.geometries[c] = g + end + end +end + +return fair diff --git a/src/layouts.lua b/src/layouts/init.lua similarity index 58% rename from src/layouts.lua rename to src/layouts/init.lua index 9863543..0593ed3 100644 --- a/src/layouts.lua +++ b/src/layouts/init.lua @@ -1,4 +1,6 @@ local awful = require('awful') +local fair_col = require('src.layouts.fair_col') +local tile_col = require('src.layouts.tile_col') tag.connect_signal("request::default_layouts", function() awful.layout.append_default_layouts({ @@ -8,12 +10,8 @@ tag.connect_signal("request::default_layouts", function() awful.layout.suit.tile.left, awful.layout.suit.tile.bottom, awful.layout.suit.tile.top, - awful.layout.suit.spiral, - awful.layout.suit.spiral.dwindle, - awful.layout.suit.max, - awful.layout.suit.max.fullscreen, - awful.layout.suit.magnifier, - awful.layout.suit.corner.nw, - awful.layout.suit.floating + awful.layout.suit.floating, + fair_col, + --tile_col }) end) diff --git a/src/layouts/tile_col.lua b/src/layouts/tile_col.lua new file mode 100644 index 0000000..373a9b5 --- /dev/null +++ b/src/layouts/tile_col.lua @@ -0,0 +1,120 @@ +local tag = require("awful.tag") +local client = require("awful.client") +local ipairs = ipairs +local math = math +local capi = { + mouse = mouse, + screen = screen, + mousegrabber = mousegrabber +} + +local debug = require('gears.debug').dump + +local function apply_size_hints(c, width, height, useless_gap) + local bw = c.border_width + width, height = width - 2 * bw - useless_gap, height - 2 * bw - useless_gap + _, height = c:apply_size_hints(math.max(1, width), math.max(1, height)) + return height + 2 * bw + useless_gap +end + +local tile = {} +tile.name = "tilec" + +function tile.arrange(s) + local t = s.tag or capi.screen[s.screen].selected_tag + local gs = s.geometries + local cls = s.clients + local useless_gap = s.useless_gap + local nmaster = #cls + local wa = s.workarea + + local fact = tag.getdata(t).windowfact + if not fact then + fact = {} + tag.getdata(t).windowfact = fact + end + + if #cls > 0 then + debug(fact) + -- find our total values + local total_fact = 0 + local min_fact = 1 + for i = 1,nmaster do + -- calculate the height + if not fact[i] then + fact[i] = min_fact + else + min_fact = math.min(fact[i],min_fact) + end + total_fact = total_fact + fact[i] + end + + local coord = wa.y + local unused = wa.height + for c = 1,nmaster do + local geom = {} + geom.width = wa.width + geom.height = math.max(1, math.floor(unused * fact[c] / total_fact)) + geom.x = wa.x + geom.y = coord + gs[cls[c]] = geom + local height = apply_size_hints(cls[c], geom.width, geom.height, useless_gap) + coord = coord + height + unused = unused - height + total_fact = total_fact - fact[c] + end + end + +end + +function tile.skip_gap(nclients, t) return nclients == 1 and t.master_fill_policy == "expand" end + +function tile.mouse_resize_handler(c, _, _, _) + local wa = c.screen.workarea + local t = c.screen.selected_tag + local useless_gap = t.gap + local g = c:geometry() + local i = client.idx(c).idx + local fact = tag.getdata(t).windowfact + if not fact then + fact = {} + tag.getdata(t).windowfact = fact + end + local offset = 0 + if g.height+useless_gap+15 > wa.height then + offset = g.height * .5 + elseif g.y+g.height+useless_gap+15 <= wa.y+wa.height then + offset = g.height + end + + + print(g.y + (((capi.mouse.coords().y - g.y) >= (g.height / 2)) and g.height or 0)) + capi.mouse.coords { x = wa.x + wa.width * 0.5, y = g.y + offset } + local prev_coords = {} + capi.mousegrabber.run(function(coords) + if not c.valid then return false end + + for _, v in ipairs(coords.buttons) do + if v then + prev_coords = { y = coords.y } + + local geom = c:geometry() + + local wfact + if (geom.y + geom.height + useless_gap + 15) > (wa.y + wa.height) then + wfact = (geom.y + geom.height - coords.y) / wa.height + else + wfact = (coords.y - geom.y) / wa.height + end + + fact[i] = math.min(math.max(wfact, 0.01), 0.99) + t:emit_signal("property::windowfact") + print(fact[i]) + return true + end + end + return (prev_coords.y == coords.y) + end, "sb_v_double_arrow") +end + +return tile diff --git a/src/theme/init.lua b/src/theme/init.lua index dd7818c..7f6a16d 100644 --- a/src/theme/init.lua +++ b/src/theme/init.lua @@ -5,6 +5,7 @@ local confdir = require('src.util.path').conf_dir ---@class Settings ---@field wallpaper? string +---@field vallpaper? string ---@field systray_screen? integer ---@field show_battery? boolean ---@return Settings @@ -29,6 +30,7 @@ local settings = load_settings() return { confdir = confdir, wallpaper = confdir .. '/wallpapers/' .. (settings.wallpaper or 'wall.png'), + vallpaper = confdir .. '/wallpapers/' .. (settings.vallpaper or 'vall0.png'), font = 'Terminus 8', font_mono = 'Mononoki Nerd Font Mono 10', bg_normal = '#000000', @@ -83,6 +85,7 @@ return { layout_fullscreen = confdir .. '/icons/fullscreen.png', layout_magnifier = confdir .. '/icons/magnifier.png', layout_floating = confdir .. '/icons/floating.png', + layout_fairc = confdir .. '/icons/fairc.png', titlebar_close_button_normal = confdir .. '/icons/titlebar/close_normal.png', titlebar_close_button_focus = confdir .. '/icons/titlebar/close_focus.png', titlebar_minimize_button_normal = confdir .. '/icons/titlebar/minimize_normal.png', diff --git a/src/theme/wibar.lua b/src/theme/wibar.lua index 5c010c6..f92d6d0 100644 --- a/src/theme/wibar.lua +++ b/src/theme/wibar.lua @@ -4,6 +4,7 @@ local wibox = require('wibox') local dpi = require('beautiful.xresources').apply_dpi local theme = require('src.theme') local widgets = require('src.widgets') +local fair_col = require('src.layouts.fair_col') local function create_separator() return wibox.widget.separator({ orientation = 'vertical', forced_width = 7, thickness = 1, span_ratio = 0.7, color = theme.fg_normal }) @@ -37,12 +38,18 @@ local tasklist_buttons = gears.table.join( awful.button({}, 1, function(c) c:emit_signal('request::activate', 'tasklist', { raise = true }) end) ) -screen.connect_signal('property::geometry', function(s) gears.wallpaper.maximized(theme.wallpaper, s, true) end) +local function wallpaper(s) + local is_v = s.geometry.height > s.geometry.width + gears.wallpaper.maximized(is_v and theme.vallpaper or theme.wallpaper, s, true) +end + +screen.connect_signal('property::geometry', wallpaper) return function(s) - gears.wallpaper.maximized(theme.wallpaper, s, true) + wallpaper(s) - awful.tag.new({'1', '2', '3', '4', '5'}, s, awful.layout.suit.fair) + local is_v = s.geometry.height > s.geometry.width + awful.tag.new({'1', '2', '3', '4', '5'}, s, is_v and fair_col or awful.layout.suit.fair) local tasklist = awful.widget.tasklist({ screen = s, diff --git a/wallpapers/vall0.png b/wallpapers/vall0.png new file mode 100644 index 0000000..e6e7fbb Binary files /dev/null and b/wallpapers/vall0.png differ