ADD EDIT + TOOLS

This commit is contained in:
2025-11-21 12:34:11 +01:00
parent 16fc39c343
commit 57e8203eb2
11 changed files with 741 additions and 527 deletions

View File

@@ -1,421 +0,0 @@
#!/usr/bin/env python3
##############################################
# Auto Qtile keybindings - image generator #
# Qmade version of the configuration #
##############################################
import getopt
import os
import sys
import cairocffi as cairo
from cairocffi import ImageSurface
this_dir = os.path.dirname(__file__)
base_dir = os.path.abspath(os.path.join(this_dir, ".."))
sys.path.insert(0, base_dir)
BUTTON_NAME_Y = 65
BUTTON_NAME_X = 10
COMMAND_Y = 20
COMMAND_X = 10
LEGEND = ["modifiers", "layout", "group", "window", "other"]
CUSTOM_KEYS = {
"Backspace": 2,
"Tab": 1.5,
"\\": 1.5,
"Return": 2.4533,
"shift": 2,
"space": 5,
}
class Button:
def __init__(self, key, x, y, width, height):
self.key = key
self.x = x
self.y = y
self.width = width
self.height = height
class Pos:
WIDTH = 78
HEIGHT = 70
GAP = 5
def __init__(self, x, y):
self.x = x
self.row_x = x
self.y = y
self.custom_width = {}
for i, val in CUSTOM_KEYS.items():
self.custom_width[i] = val * self.WIDTH
def get_pos(self, name):
if name in self.custom_width:
width = self.custom_width[name]
else:
width = self.WIDTH
info = Button(name, self.x, self.y, width, self.HEIGHT)
self.x = self.x + self.GAP + width
return info
def skip_x(self, times=1):
self.x = self.x + self.GAP + times * self.WIDTH
def next_row(self):
self.x = self.row_x
self.y = self.y + self.GAP + self.HEIGHT
class KeyboardPNGFactory:
def __init__(self, modifiers, keys):
self.keys = keys
self.modifiers = modifiers.split("-")
self.key_pos = self.calculate_pos(20, 140)
def rgb_red(self, context):
context.set_source_rgb(0.8431372549, 0.3725490196, 0.3725490196)
def rgb_green(self, context):
context.set_source_rgb(0.6862745098, 0.6862745098, 0)
def rgb_yellow(self, context):
context.set_source_rgb(1, 0.6862745098, 0)
def rgb_cyan(self, context):
context.set_source_rgb(0.5137254902, 0.6784313725, 0.6784313725)
def rgb_violet(self, context):
context.set_source_rgb(0.831372549, 0.5215686275, 0.6784313725)
def calculate_pos(self, x, y):
pos = Pos(x, y)
key_pos = {}
for c in "`1234567890-=":
key_pos[c] = pos.get_pos(c)
key_pos["Backspace"] = pos.get_pos("Backspace")
pos.next_row()
key_pos["Tab"] = pos.get_pos("Tab")
for c in "qwertyuiop[]\\":
key_pos[c] = pos.get_pos(c)
pos.next_row()
pos.skip_x(1.6)
for c in "asdfghjkl;'":
key_pos[c] = pos.get_pos(c)
key_pos["Return"] = pos.get_pos("Return")
pos.next_row()
key_pos["shift"] = pos.get_pos("shift")
for c in "zxcvbnm":
key_pos[c] = pos.get_pos(c)
key_pos["period"] = pos.get_pos("period")
key_pos["comma"] = pos.get_pos("comma")
key_pos["/"] = pos.get_pos("/")
pos.next_row()
key_pos["control"] = pos.get_pos("control")
pos.skip_x()
key_pos["mod4"] = pos.get_pos("mod4")
key_pos["mod1"] = pos.get_pos("mod1")
key_pos["space"] = pos.get_pos("space")
key_pos["Print"] = pos.get_pos("Print")
pos.skip_x(3)
key_pos["Up"] = pos.get_pos("Up")
pos.next_row()
pos.skip_x(12.33)
key_pos["Left"] = pos.get_pos("Left")
key_pos["Down"] = pos.get_pos("Down")
key_pos["Right"] = pos.get_pos("Right")
pos.next_row()
for legend in LEGEND:
key_pos[legend] = pos.get_pos(legend)
pos.skip_x(5)
key_pos["Button1"] = pos.get_pos("Button1")
key_pos["Button2"] = pos.get_pos("Button2")
key_pos["Button3"] = pos.get_pos("Button3")
pos.next_row()
key_pos["FN_KEYS"] = pos.get_pos("FN_KEYS")
return key_pos
def render(self, filename):
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 1280, 800)
context = cairo.Context(surface)
with context:
context.set_source_rgb(1, 1, 1)
context.paint()
context.move_to(40, 50)
context.set_font_size(34)
context.show_text("Qmade - Keybindings for Qtile")
context.move_to(40, 80)
context.set_font_size(22)
if len([i for i in self.modifiers if i]):
context.show_text("Modifiers: " + ", ".join(self.modifiers))
else:
context.show_text("No modifiers used.")
for i in self.key_pos.values():
if i.key in ["FN_KEYS"]:
continue
self.draw_button(context, i.key, i.x, i.y, i.width, i.height)
# draw functional
fn = [i for i in keys.values() if i.key[:4] == "XF86"]
if len(fn):
fn_pos = self.key_pos["FN_KEYS"]
x = fn_pos.x
for i in fn:
self.draw_button(context, i.key, x, fn_pos.y, fn_pos.width, fn_pos.height)
x += Pos.GAP + Pos.WIDTH
# draw mouse base
context.rectangle(830, 670, 244, 90)
context.set_source_rgb(0, 0, 0)
context.stroke()
context.set_font_size(28)
context.move_to(900, 730)
context.show_text("MOUSE")
surface.write_to_png(filename)
def draw_button(self, context, key, x, y, width, height):
radius = 5 # Radius for the rounded corners
fn = False
if key[:4] == "XF86":
fn = True
if key in LEGEND:
if key == "modifiers":
self.rgb_red(context)
elif key == "group":
self.rgb_green(context)
elif key == "layout":
self.rgb_cyan(context)
elif key == "window":
self.rgb_yellow(context)
else:
self.rgb_violet(context)
self.rounded_rectangle(context, x, y, width, height, radius)
context.fill()
if key in self.modifiers:
self.rounded_rectangle(context, x, y, width, height, radius)
self.rgb_red(context)
context.fill()
if key in self.keys:
k = self.keys[key]
self.rounded_rectangle(context, x, y, width, height, radius)
self.set_key_color(context, k)
context.fill()
self.show_multiline(context, x + COMMAND_X, y + COMMAND_Y, k)
self.rounded_rectangle(context, x, y, width, height, radius)
context.set_source_rgb(0, 0, 0)
context.stroke()
if fn:
key = key[4:]
context.set_font_size(10)
else:
context.set_font_size(14)
context.move_to(x + BUTTON_NAME_X, y + BUTTON_NAME_Y)
context.show_text(self.translate(key))
def rounded_rectangle(self, context, x, y, width, height, radius):
context.new_path()
context.arc(x + radius, y + radius, radius, 2 * (3.14 / 2), 3 * (3.14 / 2))
context.arc(x + width - radius, y + radius, radius, 3 * (3.14 / 2), 4 * (3.14 / 2))
context.arc(x + width - radius, y + height - radius, radius, 0, 3.14 / 2)
context.arc(x + radius, y + height - radius, radius, 3.14 / 2, 2 * (3.14 / 2))
context.close_path()
def show_multiline(self, context, x, y, key):
"""Cairo doesn't support multiline. Added with word wrapping."""
c_width = 14
if key.key in CUSTOM_KEYS:
c_width *= CUSTOM_KEYS[key.key]
context.set_font_size(10)
context.set_source_rgb(0, 0, 0)
context.move_to(x, y)
words = key.command.split(" ")
words.reverse()
printable = last_word = words.pop()
while len(words):
last_word = words.pop()
if len(printable + " " + last_word) < c_width:
printable += " " + last_word
continue
context.show_text(printable)
y += 10
context.move_to(x, y)
printable = last_word
if last_word is not None:
context.show_text(printable)
def set_key_color(self, context, key):
if key.scope == "group":
self.rgb_green(context)
elif key.scope == "layout":
self.rgb_cyan(context)
elif key.scope == "window":
self.rgb_yellow(context)
else:
self.rgb_violet(context)
def translate(self, text):
dictionary = {
"period": ",",
"comma": ".",
"Left": "←",
"Down": "↓",
"Right": "→",
"Up": "↑",
"AudioRaiseVolume": "Volume up",
"AudioLowerVolume": "Volume down",
"AudioMute": "Audio mute",
"AudioMicMute": "Mic mute",
"MonBrightnessUp": "Brightness up",
"MonBrightnessDown": "Brightness down",
}
if text not in dictionary:
return text
return dictionary[text]
class KInfo:
NAME_MAP = {
"togroup": "to group",
"toscreen": "to screen",
}
def __init__(self, key):
self.key = key.key
self.command = self.get_command(key)
self.scope = self.get_scope(key)
def get_command(self, key):
if hasattr(key, "desc") and key.desc:
return key.desc
cmd = key.commands[0]
command = cmd.name
if command in self.NAME_MAP:
command = self.NAME_MAP[command]
command = command.replace("_", " ")
if len(cmd.args):
if isinstance(cmd.args[0], str):
command += " " + cmd.args[0]
return command
def get_scope(self, key):
selectors = key.commands[0].selectors
if len(selectors):
return selectors[0][0]
class MInfo(KInfo):
def __init__(self, mouse):
self.key = mouse.button
self.command = self.get_command(mouse)
self.scope = self.get_scope(mouse)
def get_kb_map(config_path=None):
from libqtile.confreader import Config
c = Config(config_path)
if config_path:
c.load()
kb_map = {}
for key in c.keys:
mod = "-".join(key.modifiers)
if mod not in kb_map:
kb_map[mod] = {}
info = KInfo(key)
kb_map[mod][info.key] = info
for mouse in c.mouse:
mod = "-".join(mouse.modifiers)
if mod not in kb_map:
kb_map[mod] = {}
info = MInfo(mouse)
kb_map[mod][info.key] = info
return kb_map
help_doc = """
usage: gen-keybinding-img [-h] [-c CONFIGFILE] [-o OUTPUT_DIR]
Qtile keybindings image generator
optional arguments:
-h, --help show this help message and exit
-c CONFIGFILE, --config CONFIGFILE
use specified configuration file. If no presented
default will be used
-o OUTPUT_DIR, --output-dir OUTPUT_DIR
set directory to export all images to
"""
if __name__ == "__main__":
config_path = os.path.expanduser("~/.config/qtile/config.py") # Set default config path
output_dir = ""
try:
opts, args = getopt.getopt(sys.argv[1:], "hc:o:", ["help=", "config=", "output-dir="])
except getopt.GetoptError:
print(help_doc)
sys.exit(2)
for opt, arg in opts:
if opt in ("-h", "--help"):
print(help_doc)
sys.exit()
elif opt in ("-c", "--config"):
config_path = arg
elif opt in ("-o", "--output-dir"):
output_dir = arg
kb_map = get_kb_map(config_path)
for modifier, keys in kb_map.items():
if not modifier:
filename = "keybinding_no_modifier.png"
else:
filename = "keybinding_{}.png".format(modifier)
output_file = os.path.abspath(os.path.join(output_dir, filename))
f = KeyboardPNGFactory(modifier, keys)
f.render(output_file)

View File

@@ -5,6 +5,11 @@ pgrep -x picom >/dev/null || picom --backend xrender --vsync --no-fading-openclo
exec /usr/bin/lxpolkit & # Graphical authentication agent
# Run "ARandr" to set the desired screens with resolution and refresh rate and save it as a profile using.
# Terminal command.: autorandr --save PROFILENAME
#
# See more https://man.archlinux.org/man/extra/autorandr/autorandr.1.en
#
autorandr --change &
# This here if statement sets your background image, with feh...
@@ -30,11 +35,16 @@ fi
#kdeconnectd &
#
# Turn off the Screen after X time in seconds
xset s 2700 &
xset dpms 2700 2700 2700 &
# Run & Remove .first-login-user-setup file --------------------------------------------------------------
# Run & Remove .user-setup / .first-login-user-setup files --------------------------------------------------------------
if [ -f ~/.first-login-user-setup ]; then
. ~/.first-login-user-setup
sleep 0.69
rm -f ~/.first-login-user-setup
fi
if [ -f ~/.user-setup ]; then
. ~/.user-setup
sleep 0.69
rm -f ~/.user-setup
fi

View File

@@ -227,9 +227,9 @@ keys.extend([
])
# ScratchPads
groups.append(ScratchPad("scratchpad", [
DropDown("term1", "kitty --class=scratch", width=0.8, height=0.8, x=0.5 - (0.8 / 2), y=0.5 - (0.8 / 2), opacity=1, on_focus_lost_hide=False),
DropDown("term1", "kitty --class=scratch", width=0.8, height=0.8, x=0.5 - (0.8 / 2), y=0.5 - (0.8 / 2), opacity=1, on_focus_lost_hide=True),
DropDown("term2", "kitty --class=scratch --override background_opacity=1", width=0.8, height=0.8, x=0.5 - (0.8 / 2), y=0.5 - (0.8 / 2), opacity=1, on_focus_lost_hide=False),
DropDown("term3", "kitty --class=scratch --override background_opacity=1", width=0.8, height=0.8, x=0.5 - (0.8 / 2), y=0.5 - (0.8 / 2), opacity=1, on_focus_lost_hide=False),
DropDown("term3", "kitty --class=scratch --override background_opacity=1", width=0.8, height=0.8, x=0.5 - (0.8 / 2), y=0.5 - (0.8 / 2), opacity=1, on_focus_lost_hide=True),
DropDown("term4", "kitty --class=scratch --override background_opacity=1", width=0.9, height=0.9, x=0.5 - (0.9 / 2), y=0.5 - (0.9 / 2), opacity=1, on_focus_lost_hide=False),
DropDown("file-explorer", "kitty --class=yazi --override background_opacity=1 -e sudo yazi", width=0.8, height=0.8, x=0.5 - (0.8 / 2), y=0.5 - (0.8 / 2), opacity=1, on_focus_lost_hide=False),
DropDown("audio", "kitty --class=volume -e alsamixer", width=0.8, height=0.8, x=0.5 - (0.8 / 2), y=0.5 - (0.8 / 2), opacity=1),

51
src/grub/grub.cfg Normal file
View File

@@ -0,0 +1,51 @@
if [ x$feature_default_font_path = xy ] ; then
font=unicode
else
font=$prefix/font.pf2
fi
if loadfont $font ; then
set gfxmode=1024x768
set gfxpayload=keep
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
insmod gfxterm
insmod png
# Added as a workaround for #1110759
echo "Loading bootloader..."
terminal_output gfxterm
fi
if background_image /isolinux/splash.png; then
set color_normal=light-gray/black
set color_highlight=white/black
elif background_image /splash.png; then
set color_normal=light-gray/black
set color_highlight=white/black
else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
fi
insmod play
play 960 440 1 0 4 440 1
set theme=/boot/grub/theme/1
set timeout=5
set default=0
menuentry --hotkey=g 'Graphical Install' {
set background_color=black
linux /install.amd/vmlinuz vga=788 auto=true file=/cdrom/preseed.cfg --- quiet
initrd /install.amd/gtk/initrd.gz
}
menuentry 'Graphical Rescue Mode' {
set background_color=black
linux /install.amd/vmlinuz vga=788 rescue/enable=true --- quiet
initrd /install.amd/gtk/initrd.gz
}
menuentry --hotkey=s 'Install with speech synthesis' {
set background_color=black
linux /install.amd/vmlinuz vga=788 auto=true file=/cdrom/preseed.cfg speakup.synth=soft --- quiet
initrd /install.amd/gtk/initrd.gz
}

BIN
src/grub/splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

@@ -1,64 +0,0 @@
#!/usr/bin/env bash
# Debian ISO Remastering for QMADE - https://github.com/ITmail-dk/qmade/
# sudo apt install -y wget git xorriso isolinux p7zip-full fakeroot binutils
DEBIAN_ISO_URL=https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/
GET_ISO_NAME=$(curl -s https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/ | grep -oP 'debian-\d+(?:\.\d+)+-amd64-netinst\.iso' | head -n 1)
PRESEED_ISO_NAME=QMADE-Debian
#WORK_DIR=$(pwd)
ISO_WORK_TMP=iso-extract
# Setup the environment for creating the new ISO version.
function setup() {
sudo apt update && sudo apt install -y wget git xorriso isolinux p7zip-full fakeroot binutils
if [ ! -f Debian-source.iso ]; then
wget -O Debian-source.iso $DEBIAN_ISO_URL/"$GET_ISO_NAME"
fi
xorriso -osirrox on -indev Debian-source.iso -extract / $ISO_WORK_TMP
sudo chmod -R +w $ISO_WORK_TMP
sudo mkdir -p $ISO_WORK_TMP/var/cache/apt/archives
if [ ! -f preseed.cfg ]; then
wget https://raw.githubusercontent.com/ITmail-dk/qmade/refs/heads/main/preseed.cfg
fi
sudo cp preseed.cfg $ISO_WORK_TMP
sudo sed -i 's/append vga/append auto=true priority=critical vga/' $ISO_WORK_TMP/isolinux/gtk.cfg
sudo sed -i '/spkgtk\.cfg/d; /spk\.cfg/d' $ISO_WORK_TMP/isolinux/menu.cfg
sudo sed -i 's/--- quiet/--- quiet file=\/cdrom\/preseed.cfg/' $ISO_WORK_TMP/isolinux/gtk.cfg
sudo sed -i '0,/--- quiet/ s/--- quiet/--- quiet file=\/cdrom\/preseed.cfg/' $ISO_WORK_TMP/boot/grub/grub.cfg
sudo apt reinstall --download-only -y -o Dir::Cache="./" -o Dir::Cache::archives="iso-extract/var/cache/apt/archives" \
bash-completion xserver-xorg x11-utils xinit acl arandr autorandr picom fwupd colord mesa-utils htop wget curl git tmux \
numlockx kitty neovim xdg-utils cups cups-common lm-sensors fancontrol xbacklight brightnessctl unzip network-manager \
dnsutils dunst libnotify-bin notify-osd xsecurelock pm-utils rofi 7zip jq poppler-utils fd-find ripgrep zoxide sddm \
imagemagick nsxiv mpv flameshot mc thunar gvfs gvfs-backends parted gparted mpd mpc ncmpcpp fzf ccrypt xarchiver \
notepadqq font-manager fontconfig fontconfig-config fonts-recommended fonts-liberation fonts-freefont-ttf \
fonts-noto-core libfontconfig1 pipewire pipewire-audio pipewire-alsa pipewire-pulse pipewire-jack wireplumber \
libspa-0.2-bluetooth pavucontrol alsa-utils qpwgraph sddm-theme-breeze sddm-theme-maui ffmpeg cmake \
policykit-1-gnome remmina libreoffice keynav
sudo chmod -R +r iso-extract/var/
make
}
# Make a new ISO file after removing the old one if it exists.
function make() {
if [ -d $ISO_WORK_TMP ]; then
if [ -f $PRESEED_ISO_NAME.iso ]; then rm $PRESEED_ISO_NAME.iso; fi
xorriso -as mkisofs -o $PRESEED_ISO_NAME.iso -V "Debian QMADE" -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -isohybrid-gpt-basdat $ISO_WORK_TMP
ls -lah ./*.iso
else
echo "$ISO_WORK_TMP does not exist, runing setup..."
setup
fi
}
function usb() {
lsblk
echo -en "Enter the name of the USB Disk so sda, sdb etc..: "
read -r USB_DISK
clear
sudo dd bs=4M status=progress conv=fsync oflag=direct if="$(pwd)"/$PRESEED_ISO_NAME.iso of=/dev/"$USB_DISK"
echo "ISO to USB All done."
}
# Run the function by, function_name
"$@" make