.
This commit is contained in:
1 parent
0fd684a6b9
commit
7d18e43e3d
6 files changed
+79
-69
No files matched your search
@@ -4,18 +4,13 @@ from loguru import logger
|
||||
|
||||
from fabric import Application
|
||||
from fabric.utils import get_relative_path, monitor_file
|
||||
from modules.bar.bar import Bar
|
||||
from modules.launcher.launcher import Launcher
|
||||
from modules.notifications import NotificationPopup
|
||||
from modules.osd import SystemOSD
|
||||
from services.brightness import Brightness
|
||||
from services.screen_record import ScreenRecorder
|
||||
from modules import Bar, Launcher, NotificationPopup, OSDContainer
|
||||
from services import Brightness, ScreenRecorder
|
||||
|
||||
|
||||
def apply_style(app: Application):
|
||||
logger.info("[Main] CSS applied")
|
||||
app.set_stylesheet_from_file(get_relative_path("style/main.css"))
|
||||
# app.set_stylesheet_from_file(f"/home/{os.getlogin()}/.cache/material/colors.css")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -26,7 +21,7 @@ if __name__ == "__main__":
|
||||
bar = Bar()
|
||||
launcher = Launcher()
|
||||
launcher.hide()
|
||||
systemOverlay = SystemOSD()
|
||||
systemOverlay = OSDContainer()
|
||||
notif = NotificationPopup()
|
||||
app = Application(
|
||||
"fabric-bar",
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
from .brightness import Brightness
|
||||
from .material_icon import MaterialIcon
|
||||
from .screen_record import ScreenRecorder
|
||||
|
||||
__all__ = [
|
||||
"Brightness",
|
||||
"MaterialIcon",
|
||||
"ScreenRecorder",
|
||||
]
|
||||
@@ -1,9 +1,10 @@
|
||||
import os
|
||||
|
||||
from fabric.core.service import Service, Signal, Property
|
||||
from fabric.utils import exec_shell_command, exec_shell_command_async, monitor_file
|
||||
from gi.repository import GLib
|
||||
|
||||
from fabric.core.service import Property, Service, Signal
|
||||
from fabric.utils import exec_shell_command, exec_shell_command_async, monitor_file
|
||||
|
||||
# In the future, use GUdev to get ehe brightness devices
|
||||
|
||||
|
||||
@@ -36,12 +37,10 @@ class Brightness(Service):
|
||||
# )
|
||||
|
||||
@Signal
|
||||
def screen(self, value: int) -> None:
|
||||
...
|
||||
def screen(self, value: int) -> None: ...
|
||||
|
||||
@Signal
|
||||
def kbd(self, value: int) -> None:
|
||||
...
|
||||
def kbd(self, value: int) -> None: ...
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.screen_backlight_path = "/sys/class/backlight/" + screen
|
||||
|
||||
File renamed without changes.
@@ -3,7 +3,7 @@ import subprocess
|
||||
|
||||
from fabric.core.service import Service
|
||||
from fabric.utils import exec_shell_command
|
||||
from gi.repository import GLib, Gio
|
||||
from gi.repository import Gio, GLib
|
||||
from loguru import logger
|
||||
|
||||
|
||||
@@ -31,21 +31,20 @@ class ScreenRecorder(Service):
|
||||
def screenshot(self, fullscreen=False, save_copy=True):
|
||||
time = datetime.datetime.today().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
file_path = self.screenshot_path + str(time) + ".png"
|
||||
command = ["wayshot", "-f", file_path] if save_copy else ["wayshot", "--stdout"]
|
||||
|
||||
command = (
|
||||
["grimblast", "copysave", "screen", file_path]
|
||||
if save_copy
|
||||
else ["grimblast", "copy" "screen"]
|
||||
)
|
||||
if not fullscreen:
|
||||
region = exec_shell_command("slurp").split("\n")
|
||||
if region[0] == "selection cancelled":
|
||||
return
|
||||
command = command + ["-s", region[0]]
|
||||
|
||||
wayshot = subprocess.run(command, check=True, capture_output=True)
|
||||
if save_copy:
|
||||
exec_shell_command_async(f"bash -c 'wl-copy < {file_path}' ")
|
||||
self.send_screenshot_notification_file("file", file_path)
|
||||
return
|
||||
subprocess.run(["wl-copy"], input=wayshot.stdout, check=False)
|
||||
self.send_screenshot_notification_file("stdout")
|
||||
command[2] = "area"
|
||||
try:
|
||||
subprocess.run(command, check=True)
|
||||
self.send_screenshot_notification(
|
||||
file_path=file_path if file_path else None,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"[SCREENSHOT] Failed to run command: {command}")
|
||||
|
||||
def screencast_start(self, fullscreen=False):
|
||||
time = datetime.datetime.today().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
@@ -53,7 +52,7 @@ class ScreenRecorder(Service):
|
||||
area = ""
|
||||
if fullscreen:
|
||||
area = exec_shell_command("slurp")
|
||||
command = f"wf-recorder -g {area} -f {file_path} --pixel-format yuv420p"
|
||||
command = f"wf-recorder -g {area} -f {file_path}"
|
||||
|
||||
exec_shell_command_async(command)
|
||||
|
||||
@@ -61,7 +60,7 @@ class ScreenRecorder(Service):
|
||||
exec_shell_command_async("killall -INT wf-recorder")
|
||||
self.recording = False
|
||||
|
||||
def send_screenshot_notification_file(self, notify_type, file_path=None):
|
||||
def send_screenshot_notification(self, file_path=None):
|
||||
cmd = ["notify-send"]
|
||||
cmd.extend(
|
||||
[
|
||||
@@ -71,24 +70,31 @@ class ScreenRecorder(Service):
|
||||
"view=View",
|
||||
"-A",
|
||||
"edit=Edit",
|
||||
"-i",
|
||||
"camera-photo-symbolic",
|
||||
"-a",
|
||||
"Fabric Screenshot Utility",
|
||||
"-h",
|
||||
f"STRING:image-path:{file_path}",
|
||||
f"Screenshot {file_path}",
|
||||
"Screenshot Saved",
|
||||
f"Saved Screenshot at {file_path}",
|
||||
]
|
||||
) if notify_type == "file" else ["Screenshot Sent to Clipboard"]
|
||||
if file_path
|
||||
else ["Screenshot Sent to Clipboard"]
|
||||
)
|
||||
|
||||
proc = Gio.Subprocess.new(cmd, Gio.SubprocessFlags.STDOUT_PIPE)
|
||||
proc: Gio.Subprocess = Gio.Subprocess.new(cmd, Gio.SubprocessFlags.STDOUT_PIPE)
|
||||
|
||||
def do_callback(process: Gio.Subprocess, task: Gio.Task):
|
||||
try:
|
||||
_, stdout, stderr = process.communicate_utf8_finish(task)
|
||||
except Exception:
|
||||
logger.error("Failed read notification action")
|
||||
logger.error(
|
||||
f"[SCREENSHOT] Failed read notification action with error {stderr}"
|
||||
)
|
||||
return
|
||||
|
||||
out = stdout.strip("\n")
|
||||
|
||||
match out:
|
||||
match stdout.strip("\n"):
|
||||
case "files":
|
||||
exec_shell_command_async(f"xdg-open {self.screenshot_path}")
|
||||
case "view":
|
||||
|
||||
@@ -418,45 +418,46 @@ tooltip label {
|
||||
text-shadow: 2px 2px 2px @primary;
|
||||
}
|
||||
|
||||
#osd-corner {
|
||||
padding-left: 45px;
|
||||
#osd-container {
|
||||
background: @surfaceContainer;
|
||||
padding: 12px;
|
||||
border-radius: 14px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
#osd-icon image {
|
||||
color: @foreground;
|
||||
#osd-container scale {
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
#osd-corner * {
|
||||
background-color: alpha(@background, 0.9);
|
||||
#osd-container slider {
|
||||
color: @onPrimary;
|
||||
background-color: @primary;
|
||||
background-size: 20px 20px;
|
||||
min-width: 5px;
|
||||
min-height: 14px;
|
||||
border-radius: 100px;
|
||||
padding: 0px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
margin-top: -16px;
|
||||
margin-bottom: -16px;
|
||||
box-shadow:
|
||||
-4px 0px 0px 1px @surfaceContainer,
|
||||
4px 0px 0px 1px @surfaceContainer;
|
||||
}
|
||||
|
||||
#osd-progress-bar *.filled {
|
||||
background-color: @foreground;
|
||||
box-shadow: 0px 0px 2px 1px @foreground;
|
||||
#osd-container trough {
|
||||
background: @secondaryContainer;
|
||||
min-height: 10px;
|
||||
margin-right: 4px;
|
||||
border-radius: 100px;
|
||||
}
|
||||
|
||||
#osd-progress-bar * {
|
||||
border-radius: 30px;
|
||||
background-color: #202020;
|
||||
transition-property: background-color, box-shadow;
|
||||
transition-duration: 0.25s;
|
||||
transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
|
||||
/* transition: background-color 0.3s cubic-bezier(.42,0,.58,1); */
|
||||
}
|
||||
#osd-progress-bar {
|
||||
margin: 10px 5px 10px 5px;
|
||||
border-radius: 30px;
|
||||
}
|
||||
|
||||
#on-screen-display {
|
||||
border-left-width: 5px;
|
||||
border-color: @outlineVariant;
|
||||
border-style: solid;
|
||||
min-height: 300px;
|
||||
background-color: alpha(@background, 0.9);
|
||||
padding: 20px;
|
||||
border-top-left-radius: 50px;
|
||||
border-bottom-left-radius: 50px;
|
||||
#osd-container highlight {
|
||||
border-radius: 100px 0px 0px 100px;
|
||||
background: @primary;
|
||||
}
|
||||
|
||||
#notification {
|
||||
|
||||
Reference in new issue
Block a user