ediable screenshots
This commit is contained in:
@@ -52,6 +52,7 @@ gnome-text-editor # or kwrite, just notepad replacement
|
||||
btop # system monitor
|
||||
activate-linux # :/
|
||||
polkit-gnome # polkit authentication agent
|
||||
gradia # screenshots editor
|
||||
|
||||
# fonts & themes
|
||||
maplemono-nf-cn / ttf-maplemono-nf-cn-unhinted (archlinuxcn)
|
||||
|
||||
84
.scripts/screenshot.py
Executable file
84
.scripts/screenshot.py
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
|
||||
# autopep8: off
|
||||
import gi
|
||||
gi.require_version("Notify", "0.7")
|
||||
from gi.repository import Notify, GLib
|
||||
# autopep8: on
|
||||
|
||||
SCREENSHOT_DIR = os.path.join(
|
||||
os.environ.get("XDG_PICTURES_DIR", os.path.expanduser("~/Pictures")),
|
||||
"Screenshots"
|
||||
)
|
||||
# full cmd: {cmd}{filename}
|
||||
SCREENSHOT_CMDS = {
|
||||
"full": f"hyprshot -z -m output -m active -o {SCREENSHOT_DIR} -f ", # since I only have one monitor
|
||||
"area": f"hyprshot -z -m region -o {SCREENSHOT_DIR} -f ",
|
||||
"window": f"hyprshot -z -m window -o {SCREENSHOT_DIR} -f ",
|
||||
}
|
||||
# full cmd: {cmd}{filename}
|
||||
EDIT_CMD = f"gradia {SCREENSHOT_DIR}{os.sep}"
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Take screenshots with hyprshot.")
|
||||
parser.add_argument(
|
||||
"type",
|
||||
choices=SCREENSHOT_CMDS.keys(),
|
||||
help="Type of screenshot to take.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# file path
|
||||
os.makedirs(SCREENSHOT_DIR, exist_ok=True)
|
||||
filename = f"screenshot_{args.type}_{int(os.times().elapsed * 1000)}.png"
|
||||
filepath = os.path.join(SCREENSHOT_DIR, filename)
|
||||
|
||||
# take screenshot
|
||||
cmd = f"{SCREENSHOT_CMDS[args.type]} {filename}"
|
||||
os.system(cmd)
|
||||
|
||||
# sleep for a short interval
|
||||
# neccessary when in "window" mode
|
||||
GLib.usleep(300000) # 0.3 seconds
|
||||
|
||||
# check if successful
|
||||
if not os.path.isfile(filepath):
|
||||
print("Failed to take screenshot.")
|
||||
exit(1)
|
||||
|
||||
# create loop instance
|
||||
loop = GLib.MainLoop()
|
||||
editing = False
|
||||
|
||||
# edit callback
|
||||
def edit_callback(n, action, user_data):
|
||||
global editing
|
||||
editing = True
|
||||
os.system(f"{EDIT_CMD}{filename}")
|
||||
n.close()
|
||||
loop.quit()
|
||||
|
||||
# close callback
|
||||
def close_callback(n):
|
||||
global editing
|
||||
if not editing:
|
||||
loop.quit()
|
||||
|
||||
# notification
|
||||
Notify.init("Screenshot Utility")
|
||||
n = Notify.Notification.new(
|
||||
"Screenshot Taken",
|
||||
"Click to edit"
|
||||
)
|
||||
n.add_action(
|
||||
"default",
|
||||
"Default",
|
||||
edit_callback,
|
||||
None
|
||||
)
|
||||
n.connect("closed", close_callback)
|
||||
n.show()
|
||||
loop.run()
|
||||
@@ -18,4 +18,4 @@ font-size = 12
|
||||
cursor-style = bar
|
||||
adjust-cursor-thickness = 3
|
||||
|
||||
custom-shader = cursor-shaders/cursor-smear.glsl
|
||||
# custom-shader = cursor-shaders/cursor-smear.glsl
|
||||
|
||||
@@ -35,7 +35,7 @@ exec-once = hyprctl plugin load "/usr/lib/libhyprexpo.so"
|
||||
# exec-once = nwg-dock-hyprland -d -i 32 -c "fuzzel" -ico "$HOME/.config/nwg-dock-hyprland/archlinux.png"
|
||||
|
||||
# Logitech Mouse
|
||||
exec-once = solaar -w hide
|
||||
exec-once = solaar -w hide 2>&1 >/home/kolkas/solaar.log
|
||||
|
||||
# Applications associations
|
||||
exec-once = kbuildsycoca6
|
||||
|
||||
@@ -29,9 +29,9 @@ bind = , mouse:277, exec, killall rofi || rofi -show drun
|
||||
bind = Super, V, exec, pkill rofi || cliphist list | rofi -dmenu -config ~/.config/rofi/dmenu.rasi -display-columns 2 -i | cliphist decode | wl-copy # Clipboard history >> clipboard
|
||||
bind = Super, Period, exec, pkill rofi || ~/.scripts/rofi-emoji # Pick emoji >> clipboard
|
||||
bind = Ctrl+Alt, Delete, exec, pkill wlogout || wlogout -p layer-shell # [hidden]
|
||||
bind = Super+Shift, S, exec, hyprshot -z -m region # Screen snip
|
||||
bind = Super+Ctrl+Shift, S, exec, hyprshot -z -m window # Screen snip (window)
|
||||
bind = , Print, exec, hyprshot -z -m output -m eDP-1 # Screen snip (whole screen)
|
||||
bind = Super+Shift, S, exec, screenshot.py area # Screen snip
|
||||
bind = Super+Ctrl+Shift, S, exec, screenshot.py window # Screen snip (window)
|
||||
bind = , Print, exec, screenshot.py full # Screen snip (whole screen)
|
||||
# Color picker
|
||||
bind = Super+Shift, C, exec, hyprpicker -a # Pick color (Hex) >> clipboard
|
||||
# Fullscreen screenshot
|
||||
|
||||
@@ -34,6 +34,7 @@ windowrulev2 = noblur, class:^(coin)$
|
||||
windowrulev2 = bordersize 0, class:^(coin)$
|
||||
windowrulev2 = noshadow, class:^(coin)
|
||||
windowrulev2 = float, class:^(wallpaper_chooser)$
|
||||
windowrulev2 = float, class:^(be.alexandervanhee.gradia)$
|
||||
|
||||
# Picture-in-Picture
|
||||
windowrulev2 = float, title:^([Pp]icture[-\s]?[Ii]n[-\s]?[Pp]icture)(.*)$
|
||||
|
||||
Reference in New Issue
Block a user