Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion completions/caelestia.fish
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,16 @@ complete -c caelestia -n "$seen scheme && $seen set" -s 'v' -l 'variant' -d 'Set
# Screenshot
complete -c caelestia -n "$seen screenshot" -s 'r' -l 'region' -d 'Capture region'
complete -c caelestia -n "$seen screenshot" -s 'f' -l 'freeze' -d 'Freeze while selecting region'
complete -c caelestia -n "$seen screenshot" -s 'c' -l 'copy' -d 'Copy screenshot to clipboard instead of opening it'

# Record
complete -c caelestia -n "$seen record" -s 'r' -l 'region' -d 'Capture region'
complete -c caelestia -n "$seen record" -s 's' -l 'sound' -d 'Capture sound'
complete -c caelestia -n "$seen record" -s 'c' -l 'clipboard' -d 'Copy recording path to clipboard'

# Clipboard
complete -c caelestia -n "$seen clipboard" -s 'd' -l 'delete' -d 'Delete from cliboard history'
complete -c caelestia -n "$seen clipboard" -s 'd' -l 'delete' -d 'Delete from clipboard history'
complete -c caelestia -n "$seen clipboard" -s 'c' -l 'clear' -d 'Clear clipboard history'

# Wallpaper
complete -c caelestia -n "$seen wallpaper" -s 'p' -l 'print' -d 'Print the scheme for a wallpaper' -rF
Expand Down
4 changes: 4 additions & 0 deletions src/caelestia/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def parse_args() -> tuple[argparse.ArgumentParser, argparse.Namespace]:
screenshot_parser.add_argument(
"-f", "--freeze", action="store_true", help="freeze the screen while selecting a region"
)
screenshot_parser.add_argument(
"-c", "--copy", action="store_true", help="copy the screenshot to the clipboard instead of opening it"
)

# Create parser for record opts
record_parser = command_parser.add_parser("record", help="start a screen recording")
Expand All @@ -77,6 +80,7 @@ def parse_args() -> tuple[argparse.ArgumentParser, argparse.Namespace]:
clipboard_parser = command_parser.add_parser("clipboard", help="open clipboard history")
clipboard_parser.set_defaults(cls=clipboard.Command)
clipboard_parser.add_argument("-d", "--delete", action="store_true", help="delete from clipboard history")
clipboard_parser.add_argument("-c", "--clear", action="store_true", help="clear the clipboard history")

# Create parser for emoji-picker opts
emoji_parser = command_parser.add_parser("emoji", help="emoji/glyph utilities")
Expand Down
4 changes: 4 additions & 0 deletions src/caelestia/subcommands/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def __init__(self, args: Namespace) -> None:
self.args = args

def run(self) -> None:
if self.args.clear:
subprocess.run(["cliphist", "wipe"])
return

clip = subprocess.check_output(["cliphist", "list"])

if self.args.delete:
Expand Down
11 changes: 8 additions & 3 deletions src/caelestia/subcommands/screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ def run(self) -> None:

def region(self) -> None:
if self.args.region == "slurp":
subprocess.run(
["qs", "-c", "caelestia", "ipc", "call", "picker", "openFreeze" if self.args.freeze else "open"]
)
func = "open" + ("Freeze" if self.args.freeze else "") + ("Clip" if self.args.copy else "")
subprocess.run(["qs", "-c", "caelestia", "ipc", "call", "picker", func])
else:
sc_data = subprocess.check_output(["grim", "-l", "0", "-g", self.args.region.strip(), "-"])

if self.args.copy:
subprocess.run(["wl-copy"], input=sc_data)
notify("Screenshot taken", "Screenshot copied to clipboard")
return

swappy = subprocess.Popen(["swappy", "-f", "-"], stdin=subprocess.PIPE, start_new_session=True)

# Ensure stdin is not None for the type checker
Expand Down