Updated Python scripts

This commit is contained in:
itdominator 2022-02-15 20:33:19 -06:00
parent 07054947d7
commit 9148643d4b
15 changed files with 407 additions and 954 deletions

View File

@ -1,29 +0,0 @@
# Python imports
import inspect
# Gtk imports
# Application imports
from utils import Settings
from signal_classes import CrossClassSignals
class Main:
def __init__(self, args):
settings = Settings()
builder = settings.returnBuilder()
# Gets the methods from the classes and sets to handler.
# Then, builder connects to any signals it needs.
classes = [CrossClassSignals(settings)]
handlers = {}
for c in classes:
methods = inspect.getmembers(c, predicate=inspect.ismethod)
handlers.update(methods)
builder.connect_signals(handlers)
window = settings.createWindow()
window.show()

View File

@ -1,32 +0,0 @@
#!/usr/bin/python3
# Python imports
import argparse
from setproctitle import setproctitle
# Gtk imports
import gi, faulthandler, signal
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk as gtk
from gi.repository import GLib
# Application imports
from __init__ import Main
if __name__ == "__main__":
try:
setproctitle('DarkOverlay')
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, gtk.main_quit)
faulthandler.enable() # For better debug info
parser = argparse.ArgumentParser()
# Add long and short arguments
parser.add_argument("--file", "-f", default="firefox", help="JUST SOME FILE ARG.")
# Read arguments (If any...)
args = parser.parse_args()
main = Main(args)
gtk.main()
except Exception as e:
print( repr(e) )

View File

@ -0,0 +1,305 @@
#!/usr/bin/python3
# Python imports
import os, argparse
from setproctitle import setproctitle
# Lib imports
import faulthandler, signal, gi, cairo
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
from gi.repository import Gdk
# Application imports
app_name = "DarkOverlay"
def threaded(fn):
def wrapper(*args, **kwargs):
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
return wrapper
class MouseButton:
LEFT_BUTTON = 1
MIDDLE_BUTTON = 2
RIGHT_BUTTON = 3
class StateController:
isDragging = False
isCtrlDown = False
class Main(Gtk.Window):
def __init__(self, args):
super(Main, self).__init__()
self._USER_HOME = os.path.expanduser('~')
self._CONFIG_PATH = f"{self._USER_HOME}/.config/{app_name.lower()}"
self._CSS_FILE = f"{self._CONFIG_PATH}/stylesheet.css"
self._USR_PATH = f"/usr/share/{app_name.lower()}"
if not os.path.exists(self._CONFIG_PATH):
os.mkdir(self._CONFIG_PATH)
if not os.path.exists(self._CSS_FILE):
self._CSS_FILE = f"{self._USR_PATH}/stylesheet.css"
box = Gtk.Box()
separator = Gtk.Separator()
event_box = Gtk.EventBox()
self.draw_area = Gtk.DrawingArea()
self.rclick_menu = Gtk.Popover.new(separator)
box2 = Gtk.Box()
box3 = Gtk.Box()
self.brush_color_prop = Gtk.ColorButton()
label = Gtk.Label(label="Opacity")
spin_button = Gtk.SpinButton()
adjustment = spin_button.get_adjustment()
quit_button = Gtk.Button.new_from_icon_name("gtk-quit", 16)
box.set_orientation(1)
box2.set_orientation(1)
self.brush_color_prop.set_color(Gdk.Color(0,0,0))
quit_button.set_label("Quit")
spin_button.set_numeric(True)
spin_button.set_digits(2)
spin_button.set_increments(0.01, 10.00)
spin_button.set_range(0.00, 1.00)
spin_button.set_value(0.75)
self.draw_area.set_vexpand(True)
event_box.set_vexpand(True)
event_box.set_can_focus(True)
event_box.set_above_child(True)
event_box.set_visible_window(False)
box.set_vexpand(True)
self.set_keep_above(True)
box2.set_homogeneous(True)
box3.set_homogeneous(True)
box3.set_margin_top(10)
box3.set_margin_bottom(10)
self.rclick_menu.set_size_request(320, 220)
self.set_size_request(320, 220)
self.set_default_size(600, 480)
self.set_decorated(False)
self.opacityVal = 0.75
self.states = StateController()
self.area = None
self.states.isCtrlDown = False
self.states.isMouseHeld = False
self.doDrawBackground = True
self.surface = None
self.brush = None
self.aw = None # Draw area width
self.ah = None # Draw area height
rgba = self.brush_color_prop.get_rgba()
self.brushColorVal = [rgba.red, rgba.green, rgba.blue, self.opacityVal]
self.startCoords = [0.0, 0.0]
self.w1 = 0.0
self.h1 = 0.0
event_box.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
event_box.set_events(Gdk.EventMask.BUTTON_RELEASE_MASK)
event_box.set_events(Gdk.EventMask.KEY_PRESS_MASK)
event_box.set_events(Gdk.EventMask.KEY_RELEASE_MASK)
event_box.set_events(Gdk.EventMask.STRUCTURE_MASK)
self.brush_color_prop.connect("color-set", self.onColorSet)
self.draw_area.connect("configure-event", self.onConfigure)
self.draw_area.connect("draw", self.onDraw)
adjustment.connect("value-changed", self.onOpacityChange)
quit_button.connect("clicked", Gtk.main_quit)
event_box.connect("button-press-event", self.getStartCoords)
event_box.connect("button-release-event", self.popupMenu)
event_box.connect("key-press-event", self.keyActionToggle)
event_box.connect("key-release-event", self.endKeyActionToggle)
event_box.connect("motion-notify-event", self.onMotion)
self.connect("delete-event", Gtk.main_quit)
event_box.add(self.draw_area)
box.add(separator)
box.add(event_box)
box3.add(label)
box3.add(spin_button)
box2.add(self.brush_color_prop)
box2.add(box3)
box2.add(quit_button)
self.rclick_menu.add(box2)
self.add(box)
event_box.show_all()
box3.show_all()
box2.show_all()
box.show_all()
self.setWindowData()
self.show_all()
# self.set_interactive_debugging(True)
def setWindowData(self):
screen = self.get_screen()
visual = screen.get_rgba_visual()
if visual != None and screen.is_composited():
self.set_visual(visual)
# bind css file
cssProvider = Gtk.CssProvider()
cssProvider.load_from_path(self._CSS_FILE)
screen = Gdk.Screen.get_default()
styleContext = Gtk.StyleContext()
styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
self.get_style_context().add_class("regionWindow")
def onConfigure(self, area, eve, data = None):
self.area = area
aw = area.get_allocated_width()
ah = area.get_allocated_height()
self.aw = aw
self.ah = ah
self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, aw, ah)
self.brush = cairo.Context(self.surface)
self.drawBackground(self.brush, aw, ah)
return False
def onDraw(self, area, brush):
if self.surface is not None:
brush.set_source_surface(self.surface, 0.0, 0.0)
brush.paint()
else:
print("No surface info...")
return False
# Draw background white
def drawBackground(self, brush, aw, ah):
rgba = self.brushColorVal
brush.rectangle(0, 0, aw, ah) # x, y, width, height
brush.set_source_rgba(rgba[0], rgba[1], rgba[2], rgba[3]) # x, y, width, height
if not self.doDrawBackground: # If transparent or white
self.brush.set_operator(0);
brush.fill()
self.brush.set_operator(1); # reset the brush after filling bg...
def onColorSet(self, widget):
rgba = widget.get_rgba()
self.brushColorVal = [rgba.red, rgba.green, rgba.blue, self.opacityVal]
self.draw_area.queue_draw()
self.draw_area.emit("configure_event", Gdk.Event())
def onOpacityChange(self, widget):
self.opacityVal = widget.get_value()
self.brushColorVal[3] = self.opacityVal
self.draw_area.queue_draw()
self.draw_area.emit("configure_event", Gdk.Event())
def popupMenu(self, widget, eve):
self.states.isMouseHeld = False
if eve.type == Gdk.EventType.BUTTON_RELEASE and eve.button == MouseButton.RIGHT_BUTTON:
self.rclick_menu.popup()
def getStartCoords(self, widget, eve):
if eve.type == Gdk.EventType.BUTTON_PRESS and eve.button == MouseButton.LEFT_BUTTON:
self.startCoords = [eve.x, eve.y] # Used for delta calculations
self.w1 = self.get_size()[0] # Ref window width
self.h1 = self.get_size()[1] # Ref window height
self.states.isMouseHeld = True # State check for when updating width 'n height
def keyActionToggle(self, widget, eve):
key_id = Gdk.keyval_name(eve.keyval).upper()
if key_id in ["CONTROL_R", "CONTROL_L"]:
self.states.isCtrlDown = True
def endKeyActionToggle(self, widget, eve):
key_id = Gdk.keyval_name(eve.keyval).upper()
if key_id in ["CONTROL_R", "CONTROL_L"]:
self.states.isCtrlDown = False
def onMotion(self, widget, eve):
if self.states.isMouseHeld:
if self.states.isCtrlDown is False:
px1 = self.get_position()[0] # Ref window x
py1 = self.get_position()[1] # Ref window y
# Getting deltas of movement inner to draw event box
x1 = self.startCoords[0]
y1 = self.startCoords[1]
x2 = eve.x
y2 = eve.y
px = 0
py = 0
# Calculate that to actual posion change
if x2 > x1: # Is growing
px = px1 + (x2 - x1)
else: # Is shrinking
px = px1 - (x1 - x2)
if y2 > y1: # Is growing
py = py1 + (y2 - y1)
else: # Is shrinking
py = py1 - (y1 - y2)
self.move(px, py)
if self.states.isCtrlDown:
x1 = self.startCoords[0]
y1 = self.startCoords[1]
x2 = eve.x
y2 = eve.y
w = 0
h = 0
if x2 > x1: # Is growing
w = self.w1 + (x2 - x1)
else: # Is shrinking
w = self.w1 - (x1 - x2)
if y2 > y1: # Is growing
h = self.h1 + (y2 - y1)
else: # Is shrinking
h = self.h1 - (y1 - y2)
self.resize(w, h)
if __name__ == "__main__":
try:
setproctitle(f"{app_name}")
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, Gtk.main_quit)
faulthandler.enable() # For better debug info
parser = argparse.ArgumentParser()
# Add long and short arguments
parser.add_argument("--file", "-f", default="firefox", help="JUST SOME FILE ARG.")
# Read arguments (If any...)
args = parser.parse_args()
main = Main(args)
Gtk.main()
except Exception as e:
print( repr(e) )

View File

@ -1,13 +0,0 @@
#!/bin/bash
# set -o xtrace ## To debug scripts
# set -o errexit ## To exit on error
# set -o errunset ## To exit if a variable is referenced but not set
function main() {
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
source "/home/abaddon/Portable_Apps/py-venvs/pycornia-venv/bin/activate"
python "${SCRIPTPATH}"
}
main $@;

View File

@ -1,172 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkApplicationWindow" id="Main_Window">
<property name="width_request">320</property>
<property name="height_request">220</property>
<property name="can_focus">False</property>
<property name="window_position">center</property>
<property name="default_width">600</property>
<property name="default_height">480</property>
<property name="icon">darkness.png</property>
<property name="skip_pager_hint">True</property>
<property name="decorated">False</property>
<property name="gravity">center</property>
<property name="has_resize_grip">True</property>
<property name="show_menubar">False</property>
<child type="titlebar">
<placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSeparator" id="separator1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEventBox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
<property name="above_child">True</property>
<signal name="button-press-event" handler="getStartCoords" swapped="no"/>
<signal name="button-release-event" handler="popupMenu" swapped="no"/>
<signal name="key-press-event" handler="keyActionToggle" swapped="no"/>
<signal name="key-release-event" handler="endKeyActionToggle" swapped="no"/>
<signal name="motion-notify-event" handler="onMotion" swapped="no"/>
<child>
<object class="GtkDrawingArea" id="drawArea">
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="configure-event" handler="onConfigure" swapped="no"/>
<signal name="draw" handler="onDraw" swapped="no"/>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<style>
<class name="regionWindow"/>
</style>
</object>
<object class="GtkListStore" id="monitorStore">
<columns>
<!-- column-name Monitors -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkAdjustment" id="opacityAdjustment">
<property name="lower">0.01</property>
<property name="upper">1</property>
<property name="value">0.75</property>
<property name="step_increment">0.01</property>
<property name="page_increment">10</property>
<signal name="value-changed" handler="onOpacityChange" swapped="no"/>
</object>
<object class="GtkPopover" id="rClickMenu">
<property name="width_request">320</property>
<property name="height_request">220</property>
<property name="can_focus">False</property>
<property name="relative_to">separator1</property>
<property name="constrain_to">none</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkColorButton" id="brushColorProp">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
<property name="rgba">rgb(0,0,0)</property>
<signal name="color-set" handler="onColorSet" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">10</property>
<property name="margin_bottom">10</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
<property name="label" translatable="yes">Opacity</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">opacityAdjustment</property>
<property name="climb_rate">0.01</property>
<property name="digits">2</property>
<property name="value">0.75</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="close_app" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -1,187 +0,0 @@
# Python imports
import threading, subprocess, os, cairo
# Gtk imports
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
# Application imports
def threaded(fn):
def wrapper(*args, **kwargs):
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
return wrapper
class MouseButton:
LEFT_BUTTON = 1
MIDDLE_BUTTON = 2
RIGHT_BUTTON = 3
class StateController:
isDragging = False
isCtrlDown = False
class CrossClassSignals:
def __init__(self, settings):
self.settings = settings
self.builder = self.settings.returnBuilder()
self.window = self.builder.get_object("Main_Window")
self.drawArea = self.builder.get_object("drawArea")
self.brushColorProp = self.builder.get_object("brushColorProp")
self.wh = self.builder.get_object("wh")
self.xy = self.builder.get_object("xy")
self.opacityVal = 0.75
self.states = StateController()
self.area = None
self.states.isCtrlDown = False
self.states.isMouseHeld = False
self.doDrawBackground = True
self.surface = None
self.brush = None
self.aw = None # Draw area width
self.ah = None # Draw area height
rgba = self.brushColorProp.get_rgba()
self.brushColorVal = [rgba.red, rgba.green, rgba.blue, self.opacityVal]
self.startCoords = [0.0, 0.0]
self.w1 = 0.0
self.h1 = 0.0
self.window.set_keep_above(True)
def onConfigure(self, area, eve, data = None):
self.area = area
aw = area.get_allocated_width()
ah = area.get_allocated_height()
self.aw = aw
self.ah = ah
self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, aw, ah)
self.brush = cairo.Context(self.surface)
self.drawBackground(self.brush, aw, ah)
return False
def onDraw(self, area, brush):
if self.surface is not None:
brush.set_source_surface(self.surface, 0.0, 0.0)
brush.paint()
else:
print("No surface info...")
return False
# Draw background white
def drawBackground(self, brush, aw, ah):
rgba = self.brushColorVal
brush.rectangle(0, 0, aw, ah) # x, y, width, height
brush.set_source_rgba(rgba[0], rgba[1], rgba[2], rgba[3]) # x, y, width, height
if not self.doDrawBackground: # If transparent or white
self.brush.set_operator(0);
brush.fill()
self.brush.set_operator(1); # reset the brush after filling bg...
def onColorSet(self, widget):
rgba = widget.get_rgba()
self.brushColorVal = [rgba.red, rgba.green, rgba.blue, self.opacityVal]
self.drawArea.queue_draw()
self.drawArea.emit("configure_event", gdk.Event())
def onOpacityChange(self, widget):
self.opacityVal = widget.get_value()
self.brushColorVal[3] = self.opacityVal
self.drawArea.queue_draw()
self.drawArea.emit("configure_event", gdk.Event())
def popupMenu(self, widget, eve):
self.states.isMouseHeld = False
if eve.type == gdk.EventType.BUTTON_RELEASE and eve.button == MouseButton.RIGHT_BUTTON:
self.builder.get_object("rClickMenu").popup()
def getStartCoords(self, widget, eve):
if eve.type == gdk.EventType.BUTTON_PRESS and eve.button == MouseButton.LEFT_BUTTON:
self.startCoords = [eve.x, eve.y] # Used for delta calculations
self.w1 = self.window.get_size()[0] # Ref window width
self.h1 = self.window.get_size()[1] # Ref window height
self.states.isMouseHeld = True # State check for when updating width 'n height
def keyActionToggle(self, widget, eve):
key_id = gdk.keyval_name(eve.keyval).upper()
if key_id in ["CONTROL_R", "CONTROL_L"]:
self.states.isCtrlDown = True
def endKeyActionToggle(self, widget, eve):
key_id = gdk.keyval_name(eve.keyval).upper()
if key_id in ["CONTROL_R", "CONTROL_L"]:
self.states.isCtrlDown = False
def onMotion(self, widget, eve):
if self.states.isMouseHeld:
if self.states.isCtrlDown is False:
px1 = self.window.get_position()[0] # Ref window x
py1 = self.window.get_position()[1] # Ref window y
# Getting deltas of movement inner to draw event box
x1 = self.startCoords[0]
y1 = self.startCoords[1]
x2 = eve.x
y2 = eve.y
px = 0
py = 0
# Calculate that to actual posion change
if x2 > x1: # Is growing
px = px1 + (x2 - x1)
else: # Is shrinking
px = px1 - (x1 - x2)
if y2 > y1: # Is growing
py = py1 + (y2 - y1)
else: # Is shrinking
py = py1 - (y1 - y2)
self.window.move(px, py)
if self.states.isCtrlDown:
x1 = self.startCoords[0]
y1 = self.startCoords[1]
x2 = eve.x
y2 = eve.y
w = 0
h = 0
if x2 > x1: # Is growing
w = self.w1 + (x2 - x1)
else: # Is shrinking
w = self.w1 - (x1 - x2)
if y2 > y1: # Is growing
h = self.h1 + (y2 - y1)
else: # Is shrinking
h = self.h1 - (y1 - y2)
self.window.resize(w, h)
def close_app(self, widget):
gtk.main_quit()

View File

@ -1 +0,0 @@
from .CrossClassSignals import CrossClassSignals

View File

@ -1,71 +0,0 @@
# Gtk imports
import gi, cairo
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk as gtk
from gi.repository import Gdk as gdk
# Python imports
import os
# Application imports
class Settings:
def __init__(self):
self.SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__)) + "/"
self.builder = gtk.Builder()
self.builder.add_from_file(self.SCRIPT_PTH + "../resources/Main_Window.glade")
# 'Filters'
self.images = ('.png', '.jpg', '.jpeg', '.gif')
HOME_PATH = os.path.expanduser('~')
self.SCREENSHOTS_DIR = HOME_PATH + "/" + ".screenshots"
if not os.path.isdir(self.SCREENSHOTS_DIR):
os.mkdir(self.SCREENSHOTS_DIR)
def createWindow(self):
# Get window and connect signals
window = self.builder.get_object("Main_Window")
window.connect("delete-event", gtk.main_quit)
self.setWindowData(window)
return window
def setWindowData(self, window):
screen = window.get_screen()
visual = screen.get_rgba_visual()
if visual != None and screen.is_composited():
window.set_visual(visual)
# bind css file
cssProvider = gtk.CssProvider()
cssProvider.load_from_path(self.SCRIPT_PTH + '../resources/stylesheet.css')
screen = gdk.Screen.get_default()
styleContext = gtk.StyleContext()
styleContext.add_provider_for_screen(screen, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_USER)
def getMonitorData(self):
screen = self.builder.get_object("Main_Window").get_screen()
wdth = screen.get_width()
hght = screen.get_height()
mon0 = gdk.Rectangle()
mon0.width = wdth
mon0.height = hght
monitors = []
monitors.append(mon0)
for m in range(screen.get_n_monitors()):
monitors.append(screen.get_monitor_geometry(m))
return monitors
def returnBuilder(self): return self.builder
def returnScreenshotsDir(self): return self.SCREENSHOTS_DIR
# Filter returns
def returnImagesFilter(self): return self.images

View File

@ -1 +0,0 @@
from .Settings import Settings

View File

@ -0,0 +1,102 @@
#!/usr/bin/python3
# Python imports
import argparse
from setproctitle import setproctitle
# Gtk imports
import gi, faulthandler, signal
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GLib
# Application imports
# from __init__ import Main
class Main(Gtk.Window):
"""docstring for Main."""
def __init__(self, args):
super(Main, self).__init__()
self.args = args
width = None
height = None
try:
width = int(self.args.width)
height = int(self.args.height)
except Exception as e:
print("Invalid width or height given. Using defaults...")
width = 800
height = 600
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, Gtk.main_quit)
self.connect('visibility-notify-event', self._reset_position)
self.set_default_size(width, height)
self.set_title(f"Yolo")
# self.set_title(f"{app_name}")
# self.set_icon_from_file("/usr/share/bulkr/bulkr.png")
self.display = Gdk.Display().get_default()
self.mouse = self.display.get_default_seat().get_pointer()
self.placement = "bottom"
self.set_decorated(False)
self.show_all()
def _reset_position(self, widget, eve):
if eve.state == Gdk.VisibilityState.UNOBSCURED:
screen, mouse_x, mouse_y = self.mouse.get_position()
monitor = self.display.get_monitor_at_point(mouse_x, mouse_y)
window_w, window_h = self.get_size()
geom_rect = monitor.get_geometry()
x, y, w, h = geom_rect.x, geom_rect.y, geom_rect.width, geom_rect.height
new_x = None
new_y = None
print(f"Mouse: {mouse_x},{mouse_y}\nScreen: {w}x{h}|{x},{y}\nWindow: {window_w}x{window_h}")
if self.guake_side == "top":
new_x = (w - (window_w + ((w - window_w)/2) )) + x
new_y = y
if self.guake_side == "bottom":
new_x = (w - (window_w + ((w - window_w)/2) )) + x
new_y = (h - window_h) + y
if self.guake_side == "left":
new_x = x
new_y = (h - (window_h + ((h - window_h)/2) )) + y
if self.guake_side == "right":
new_x = (w - window_w) + x
new_y = (h - (window_h + ((h - window_h)/2) )) + y
self.move(new_x, new_y)
if __name__ == "__main__":
try:
setproctitle('<replace this>')
faulthandler.enable() # For better debug info
parser = argparse.ArgumentParser()
# Add long and short arguments
parser.add_argument("--folder", "-f", default="HOME", help="Specify a starting folder.")
parser.add_argument("--placement", "-p", default="top", help="The placement of the terminal (top, bottom, left, right).")
parser.add_argument("--key", "-k", default="f12", help="The key used to toggle the window.")
parser.add_argument("--width", "-w", default="800", help="The width of the window.")
parser.add_argument("--height", "-hh", default="600", help="The height of the window.")
# Read arguments (If any...)
args = parser.parse_args()
main = Main(args)
Gtk.main()
except Exception as e:
print( repr(e) )

View File

@ -1,339 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@ -1,26 +0,0 @@
# Keyboard-Mouse
Use Python 3 to move mouse with keyboard keys.
# To Launch:
Must use sudo as python3_xlib needs it.
<br/>
<code>
sudp python3 keyboardMouse.py
</code>
# Default keys are:
<br/>
Up: Ctrl+Shift+Up_Arrow
<br/>
Down: Ctrl+Shift+Down_Arrow
<br/>
Left: Ctrl+Shift+Left_Arrow
<br/>
Right: Ctrl+Shift+Right_Arrow
<br/>
Exit: Ctrl+Shift+C
# Needed Python Libraries are:
<code>
sudo pip3 install python3_xlib keyboard pyautogui
</code>

View File

@ -1,83 +0,0 @@
##
## Install these needed libraries if script doesn't work.
##
## sudo pip3 install python3_xlib
## sudo pip3 install keyboard pyautogui
##
##
import time
import keyboard, pyautogui
pyautogui.FAILSAFE = False # If we hit corner, that's ok
# Let piautogui make updates as quick as it can...
pyautogui.MINIMUM_DURATION = 0
pyautogui.PAUSE = 0
class Main:
def __init__(self):
self.isAcceptingMovement = False
self.sleepTime = 0.009
self.speed = 1;
self.modRate = 0; ## This controls mouse move speed by increasing it the longer the key combo is held.
self.keyCombo1 = "ctrl"
self.keyCombo2 = "shift"
self.keyCombo3 = 'end'
self.exitKey = 'c' ## Key combo exit key.
self.startRun()
def startRun(self):
print("Available Keys Are:")
print(pyautogui.KEYBOARD_KEYS)
print("\n\nTo Toggle Detection Press:")
print(self.keyCombo1 + " + " + self.keyCombo2 + " + " + self.keyCombo3)
print("Detection State: " + str(self.isAcceptingMovement))
while True:
try:
if keyboard.is_pressed(self.keyCombo1) and keyboard.is_pressed(self.keyCombo2):
self.checkDetectionState()
if self.isAcceptingMovement:
if keyboard.is_pressed('up') and keyboard.is_pressed('left'):
pyautogui.moveRel( (-self.speed - self.modRate), (-self.speed - self.modRate) );
elif keyboard.is_pressed('up') and keyboard.is_pressed('right'):
pyautogui.moveRel( (self.speed + self.modRate), (-self.speed - self.modRate) );
elif keyboard.is_pressed('down') and keyboard.is_pressed('left'):
pyautogui.moveRel( (-self.speed - self.modRate), (self.speed + self.modRate) );
elif keyboard.is_pressed('down') and keyboard.is_pressed('right'):
pyautogui.moveRel( (self.speed + self.modRate), (self.speed + self.modRate));
elif keyboard.is_pressed('up'):
pyautogui.moveRel(0, -(self.speed + self.modRate));
elif keyboard.is_pressed('down'):
pyautogui.moveRel(0, (self.speed + self.modRate));
elif keyboard.is_pressed('left'):
pyautogui.moveRel( -(self.speed + self.modRate), 0);
elif keyboard.is_pressed('right'):
pyautogui.moveRel( (self.speed + self.modRate), 0);
else:
# Allows us to reset to 0 after sleeping and incramenting from below
self.modRate = -1
time.sleep(self.sleepTime)
self.modRate += 0.2
if keyboard.is_pressed('enter'):
pyautogui.click();
elif keyboard.is_pressed(self.exitKey):
break;
except Exception as e:
print( repr(e) )
break;
def checkDetectionState(self):
if keyboard.is_pressed(self.keyCombo3):
self.isAcceptingMovement = not self.isAcceptingMovement
print("Detection State: " + str(self.isAcceptingMovement))
time.sleep(1)
## Start the program and loop untill key combo for quit is pressed
if __name__ == '__main__':
main = Main()