From 60d8edcb03660aecc5f2f36957b1939017ffde68 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 23 Dec 2024 00:45:14 -0600 Subject: [PATCH] some lua thing. lists windows okay. notsure Signed-off-by: Jeff Carr --- .gitignore | 1 + devilspie/Makefile | 36 ++++++++++++++++++++++++ devilspie/devilspie2.c | 5 +++- devilspie/devilspie2.lua | 46 +++++++++++++++++++++++++++++++ devilspie/lauxlib.h | 0 devilspie/scripts/awesome.lua | 46 +++++++++++++++++++++++++++++++ devilspie/scripts/file-header.lua | 29 +++++++++++++++++++ 7 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 devilspie/Makefile create mode 100644 devilspie/devilspie2.lua create mode 100644 devilspie/lauxlib.h create mode 100644 devilspie/scripts/awesome.lua create mode 100644 devilspie/scripts/file-header.lua diff --git a/.gitignore b/.gitignore index a42ec94..14976df 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ go.sum files/ xstartplacement +devilspie/devilspie2 diff --git a/devilspie/Makefile b/devilspie/Makefile new file mode 100644 index 0000000..55f1d62 --- /dev/null +++ b/devilspie/Makefile @@ -0,0 +1,36 @@ +PKGINC = $(shell pkg-config --cflags --libs glib-2.0 libwnck-3.0 lua5.1) + +all: worked1 + # gcc *.c -o test + +run: + # lists out windows found? + echo apt install lua-posix + ./devilspie2 -l + ./devilspie2 -w + sleep 3 + ./devilspie2 -d -e -f scripts + +worked1: + # gcc *.c -o test $(pkg-config --cflags --libs glib-2.0 libwnck-3.0 lua5.1) + gcc *.c -o devilspie2 ${PKGINC} \ + -lwnck-3 -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -llua5.1 -lX11 -lXinerama + # -lwnck-3 -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -llua5.1 -lX11 + + +try2: + gcc *.c -o test $(pkg-config --cflags --libs glib-2.0 libwnck-3.0) + +try1: + gcc *.c -o test \ + -I . \ + -I /usr/include/glib-2.0/ \ + -I /usr/lib/x86_64-linux-gnu/glib-2.0/include/ \ + -I /usr/include/gtk-3.0/ \ + -I /usr/include/pango-1.0/ \ + -I /usr/include/libwnck-3.0/ \ + -I /usr/include/harfbuzz/ \ + -I /usr/include/cairo \ + -I /usr/include/gdk-pixbuf-2.0/ \ + -I /usr/include/atk-1.0/ \ + -I /usr/include/lua5.1/ diff --git a/devilspie/devilspie2.c b/devilspie/devilspie2.c index cf9c994..1777119 100644 --- a/devilspie/devilspie2.c +++ b/devilspie/devilspie2.c @@ -47,6 +47,10 @@ #define HAVE_GTK3 #endif +#define PACKAGE "jcarr" +#define LOCALEDIR "/tmp/jcarr" +#define DEVILSPIE2_VERSION "jwc" + /** * */ @@ -237,7 +241,6 @@ void print_list(GSList *list) } } - /** * */ diff --git a/devilspie/devilspie2.lua b/devilspie/devilspie2.lua new file mode 100644 index 0000000..dc11905 --- /dev/null +++ b/devilspie/devilspie2.lua @@ -0,0 +1,46 @@ +-- Support Awesome 3.5 WM + +local posix = require("posix"); +local os = require("os"); + +local awesome = "/usr/bin/awesome-client" +if not posix.stat(awesome, "type") == "file" then + awesome = nil; +end + +-- Check for tiling mode +function is_tiling() + if awesome then + return true; + end + return false; +end + +-- Make window floating +-- Parameters: state - true to make window floating, else make window tiled +function set_tile_floating( state ) + if not awesome then + return nil; + end + + if state then state = "true" else state = "false" end + + local xid = get_window_xid(); + + local command = "echo "; + command = command .. "'"; + command = command .. " local naughty = require(\"naughty\");"; + command = command .. " local awcl = require(\"awful.client\");"; + command = command .. " local client = require(\"client\");"; + command = command .. " for k, c in pairs( client.get() ) do"; + command = command .. " if c.window == " .. xid .. " then"; + command = command .. " awcl.floating.set(c, " .. state .. ");"; + command = command .. " end"; + command = command .. " end"; + command = command .. "'"; + command = command .. " | "; + command = command .. awesome; + + debug_print("Awesome floating: " .. command); + return os.execute( command ); +end diff --git a/devilspie/lauxlib.h b/devilspie/lauxlib.h new file mode 100644 index 0000000..e69de29 diff --git a/devilspie/scripts/awesome.lua b/devilspie/scripts/awesome.lua new file mode 100644 index 0000000..dc11905 --- /dev/null +++ b/devilspie/scripts/awesome.lua @@ -0,0 +1,46 @@ +-- Support Awesome 3.5 WM + +local posix = require("posix"); +local os = require("os"); + +local awesome = "/usr/bin/awesome-client" +if not posix.stat(awesome, "type") == "file" then + awesome = nil; +end + +-- Check for tiling mode +function is_tiling() + if awesome then + return true; + end + return false; +end + +-- Make window floating +-- Parameters: state - true to make window floating, else make window tiled +function set_tile_floating( state ) + if not awesome then + return nil; + end + + if state then state = "true" else state = "false" end + + local xid = get_window_xid(); + + local command = "echo "; + command = command .. "'"; + command = command .. " local naughty = require(\"naughty\");"; + command = command .. " local awcl = require(\"awful.client\");"; + command = command .. " local client = require(\"client\");"; + command = command .. " for k, c in pairs( client.get() ) do"; + command = command .. " if c.window == " .. xid .. " then"; + command = command .. " awcl.floating.set(c, " .. state .. ");"; + command = command .. " end"; + command = command .. " end"; + command = command .. "'"; + command = command .. " | "; + command = command .. awesome; + + debug_print("Awesome floating: " .. command); + return os.execute( command ); +end diff --git a/devilspie/scripts/file-header.lua b/devilspie/scripts/file-header.lua new file mode 100644 index 0000000..d38fa34 --- /dev/null +++ b/devilspie/scripts/file-header.lua @@ -0,0 +1,29 @@ +--[[ + This file is part of devilspie2 + Copyright (C) 2023 Darren Salt + + This is an example primarily intended for use in your own + configuration files etc. without causing licence contamination. + As such, no licence conditions are attached; it may be modified and + redistributed freely. Essentially, do what you want with it. + + That said, retaining proper attribution would be appreciated. +]] +-- Optional, but probably useful. (Technical feedback would be helpful.) +set_adjust_for_decoration(true) +-- Set up some variables containing likely-to-be-referenced values +win_class = get_window_class() +win_role = get_window_role() +win_name = get_window_name() +app_name = get_application_name() +ins_name = get_class_instance_name() +if ins_name == nil then ins_name = '[nil]' end +grp_name = get_class_group_name() +if grp_name == nil then grp_name = '[nil]' end +-- Debug output ("devilspie2 -d") +decorated = get_window_is_decorated() and "yes" or "no" +debug_print("\nName: '" .. win_name .. "'\nApp: '" .. app_name .. "'\nClass: " .. win_class .. "\nRole: <" .. win_role .. ">") +debug_print ("Process: '" .. get_process_name() .. "'\nDecorated: " .. decorated) +debug_print ("Instance: '" .. ins_name .. "' & '" .. grp_name .. "'") + +-- Add your stuff here!