mirror of
https://github.com/winneon/gsu.git
synced 2026-09-10 07:16:25 -04:00
Compare commits
35 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2220791c4 | ||
|
|
b28773d43f | ||
|
|
cb75044088 | ||
|
|
ce24a0b81f | ||
|
|
d06106166d | ||
|
|
a36f2a6d0a | ||
|
|
607ac9979e | ||
|
|
c5c69bbe25 | ||
|
|
744e655f91 | ||
|
|
90ed978dc9 | ||
|
|
b682947b09 | ||
|
|
863fa97253 | ||
|
|
ca60908a20 | ||
|
|
e0346c125a | ||
|
|
1a11e9419d | ||
|
|
9d83a54e1b | ||
|
|
9016a153c3 | ||
|
|
dc7e4adf0b | ||
|
|
50e5557c40 | ||
|
|
f4e487d61f | ||
|
|
36ebbac89d | ||
|
|
faccc1aa1a | ||
|
|
d655a56930 | ||
|
|
359e351a9e | ||
|
|
469803b2de | ||
|
|
2297fc7085 | ||
|
|
27548b6e93 | ||
|
|
178bd72c29 | ||
|
|
0c533e9cb2 | ||
|
|
5c81bb561b | ||
|
|
a411eb47ea | ||
|
|
000579fb95 | ||
|
|
3427d0bb9c | ||
|
|
17afff0228 | ||
|
|
eacb29d02e |
2
LICENSE
2
LICENSE
|
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Jesse Bryan
|
||||
Copyright (c) 2017-2020 Jesse Bryan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
|||
114
README.md
114
README.md
|
|
@ -9,43 +9,137 @@ gsu (General Screenshot Utility) allows for easy capturing and uploading of imag
|
|||
* GIF capture.
|
||||
* Built-in uploading to uguu.se, streamable, and gfycat.
|
||||
* Custom uploading capability if the above services don't suit your fancy.
|
||||
* dmenu and rofi integration.
|
||||
* A clean and easy to understand CLI.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
Usage: gsu [OPTION]... SOURCE
|
||||
A general screenshot and upload utility for images, video, and gifs.
|
||||
|
||||
SOURCE defaults to $XDG_CONFIG_HOME/gsu/imgs if nothing is provided.
|
||||
The most common location for $XDG_CONFIG_HOME is ~/.config.
|
||||
|
||||
GENERAL OPTIONS
|
||||
-h, --help Show the help menu.
|
||||
-v, --version Show the current version.
|
||||
-l, --list-displays List your current displays and their resolutions.
|
||||
-u, --upload Upload after running the utility.
|
||||
--hide Minimize the current window while capturing.
|
||||
This is useful when running with --terminal to hide
|
||||
the newly opened term.
|
||||
--terminal Open interactive commands in a new terminal..
|
||||
SET THIS IF RUNNING FROM ANYTHING OTHER THAN A TERM,
|
||||
i.e. xbindkeys
|
||||
--notify Send a libnotify notification of the output.
|
||||
|
||||
UTILITY OPTIONS
|
||||
-r, --dmenu Select the one of the below options from dmenu or rofi.
|
||||
-s, --screenshot Take a screenshot. (default)
|
||||
-m, --video Record a video of the screen.
|
||||
-g, --gif Record a video and convert it to the gif format.
|
||||
|
||||
CAPTURE OPTIONS
|
||||
-n, --nocursor Hide the cursor.
|
||||
-d, --display NUM|TYPE Set the selection to a specific display.
|
||||
Can read from an argument or from stdin.
|
||||
Values: number of display, 'active', 'all' (default)
|
||||
|
||||
VIDEO OPTIONS
|
||||
-c, --countdown NUM Countdown before recording.
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
### Arch Linux
|
||||
### Package Manager
|
||||
|
||||
Install [**gsu**](https://aur.archlinux.org/packages/gsu/) or [**gsu-git**](https://aur.archlinux.org/packages/gsu-git/) from the AUR.
|
||||
* [Arch Linux (AUR): gsu](https://aur.archlinux.org/packages/gsu/)
|
||||
* [Arch Linux (AUR): gsu-git](https://aur.archlinux.org/packages/gsu-git/)
|
||||
|
||||
### Install From Source
|
||||
### Manual
|
||||
|
||||
gsu depends heavily on maim, slop, FFmpeg, curl, and jq for its functionality. To install gsu's dependencies, run the following commands in accordance to your distro.
|
||||
To install gsu's required dependencies, run the following command in accordance to your distro.
|
||||
|
||||
#### Arch Linux
|
||||
|
||||
```
|
||||
$ sudo pacman -S tar make maim ffmpeg curl jq
|
||||
$ sudo pacman -S curl jq xdotool maim slop ffmpeg
|
||||
```
|
||||
|
||||
#### Debian/Ubuntu 17.04+
|
||||
#### Ubuntu 20.04 LTS/Debian 11
|
||||
|
||||
```
|
||||
$ sudo apt-get install tar make maim ffmpeg curl jq
|
||||
$ sudo apt install curl jq xdotool maim slop ffmpeg
|
||||
```
|
||||
|
||||
#### Older Debian-based (Ubuntu 19.10/Debian 10 or prior)
|
||||
|
||||
maim, slop, and FFmpeg all have bugs in earlier versions that make gsu unusable in certain scenarios. Therefore, they must all be installed via source.
|
||||
|
||||
Afterwards, run the following command to install the remaining required dependencies.
|
||||
|
||||
```
|
||||
$ sudo apt install curl jq xdotool
|
||||
```
|
||||
|
||||
#### Other Linux or BSD
|
||||
|
||||
Install `curl`, `jq`, `xdotool`, `maim`, `slop`, and `ffmpeg` via source or your package manager of choice. *If installing by package manager, ensure that the following required versions are met.*
|
||||
|
||||
*maim*: 5.x or later
|
||||
*slop*: 7.x or later
|
||||
*FFmpeg*: 4.2.x or later
|
||||
|
||||
---
|
||||
|
||||
You can optionally install `xsel` if you want automatic URL clipboard pasting after the utility finishes an upload.
|
||||
|
||||
After installing the dependents, run the following commands to install gsu.
|
||||
|
||||
```
|
||||
$ curl -o gsu.tar.gz https://codeload.github.com/winneon/gsu/tar.gz/v1.1.1
|
||||
$ tar xvf gsu.tar.gz cd gsu-1.1.1
|
||||
$ curl -o gsu.tar.gz https://codeload.github.com/winneon/gsu/tar.gz/1.3.2
|
||||
$ tar xvf gsu.tar.gz && cd gsu-1.3.2
|
||||
$ sudo make install
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Run the utility at least once, i.e. `gsu --help`. The configuration file will be generated in `$XDG_CONFIG_HOME/gsu` if it didn't already exist. The most common location is `~/.config/gsu`.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Here are some frequent problems users may face and their respective solutions. If you have more solutions, feel free to send in an issue or pull request.
|
||||
|
||||
### The outputted capture is completely black or another solid color.
|
||||
|
||||
Make sure that you are running your DE/WM under the latest version of X11. Wayland is untested. To check, run the following command.
|
||||
|
||||
```
|
||||
$ echo $XDG_SESSION_TYPE
|
||||
```
|
||||
|
||||
If you are running X11 and the problem persists, try disabling OpenGL hardware-based acceleration by adding `--no-opengl` to your gsu command.
|
||||
|
||||
### The outputted capture has black/white sections or artifacts.
|
||||
|
||||
This is a problem with older versions of maim. Upgrade maim to 5.x or later or install via source.
|
||||
|
||||
### The capture session won't end when capturing a video or gif.
|
||||
|
||||
Versions of FFmpeg prior to 4.2.x have a bug where an `x11grab` capture sessions won't end unless forcibly killed by the system. Upgrade FFmpeg to 4.2.x or install via source.
|
||||
|
||||
### There is no audio in the captured video.
|
||||
|
||||
PulseAudio is the default audio capture device. If you do not use PulseAudio, adjust your audio capture device in the configuration file.
|
||||
|
||||
If you do use PulseAudio, use a program like `pavucontrol` to change the input device to a monitor of your audio output device. If you use PAVUcontrol, the resulting setup should look similar to below.
|
||||
|
||||

|
||||
|
||||
## Credits
|
||||
|
||||
* [Dalton Nell](https://github.com/naelstrof) for maim and slop, used for screenshot creation and selections
|
||||
* [The FFmpeg team](https://ffmpeg.org/) for ffmpeg, used for video and gif creation
|
||||
* [The FFmpeg team](https://ffmpeg.org/) for FFmpeg, used for video and gif creation
|
||||
* [Daniel Stenberg](https://github.com/bagder) for curl, used for uploading
|
||||
* [Stephen Dolan](https://github.com/stedolan) for jq, used for parsing JSON
|
||||
|
|
|
|||
|
|
@ -1,5 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Terminal. Uncomment your terminal to use,
|
||||
# or uncomment and edit one of the values to use your own terminal.
|
||||
#
|
||||
# If uncommented, be sure that the terminal you are providing is installed.
|
||||
# If --terminal is provided, a new terminal using this variable will be opened.
|
||||
# Use the string "CMD" to refer to the command that is run (gsu).
|
||||
#
|
||||
# gnome-terminal:
|
||||
#GSU_TERM=(gnome-terminal -- CMD)
|
||||
#
|
||||
# urxvt:
|
||||
#GSU_TERM=(urxvt -e bash -c "'CMD'")
|
||||
|
||||
# Audio input device. If empty, gsu defaults to pulseaudio.
|
||||
# See https://www.ffmpeg.org/ffmpeg-devices.html#Input-Devices for a list
|
||||
# of valid input devices.
|
||||
AUDIO=""
|
||||
|
||||
# Streamable email/username.
|
||||
# REQUIRED for video upload without a custom upload command.
|
||||
STREAMABLE_USER=""
|
||||
|
|
@ -16,6 +34,6 @@ S_UPLOAD=""
|
|||
# Use the string "GSUFILEOUT" to refer to your gsu operand.
|
||||
V_UPLOAD=""
|
||||
|
||||
# Custom gif upload command. Leave empty to upload to uguu.se.
|
||||
# Custom gif upload command. Leave empty to upload to gfycat.
|
||||
# Use the string "GSUFILEOUT" to refer to your gsu operand.
|
||||
G_UPLOAD=""
|
||||
|
|
|
|||
360
gsu
360
gsu
|
|
@ -1,28 +1,54 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
VERSION="1.1.1"
|
||||
VERSION="1.3.2"
|
||||
config_path="${XDG_CONFIG_HOME:-${HOME}/.config}/gsu"
|
||||
|
||||
notify() {
|
||||
echo -e "$1"
|
||||
|
||||
if [[ ! -z "$notify_arg" ]] && type -p notify-send >/dev/null; then
|
||||
notify-send "gsu" "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
print_help() {
|
||||
echo "\
|
||||
Usage: gsu [OPTION]... SOURCE
|
||||
A general screenshot and upload utility for images, video, and gifs.
|
||||
|
||||
GENERAL OPTIONS
|
||||
-h, --help Show the help menu
|
||||
-v, --version Show the current version
|
||||
SOURCE defaults to \$XDG_CONFIG_HOME/gsu/imgs if nothing is provided.
|
||||
The most common location for \$XDG_CONFIG_HOME is ~/.config.
|
||||
|
||||
-u, --upload Upload after running the utility
|
||||
-n, --nocursor Hide the cursor
|
||||
GENERAL OPTIONS
|
||||
-h, --help Show the help menu.
|
||||
-v, --version Show the current version.
|
||||
-l, --list-displays List your current displays and their resolutions.
|
||||
-u, --upload Upload after running the utility.
|
||||
--terminal Open interactive commands in a new terminal..
|
||||
SET THIS IF RUNNING FROM ANYTHING OTHER THAN A TERM,
|
||||
i.e. xbindkeys
|
||||
--hide Minimize the current window while capturing.
|
||||
This is useful when running with --terminal to hide
|
||||
the newly opened term.
|
||||
--notify Send a libnotify notification of the output.
|
||||
|
||||
UTILITY OPTIONS
|
||||
-r, --dmenu Select the one of the below options from dmenu or rofi.
|
||||
-s, --screenshot Take a screenshot. (default)
|
||||
-m, --video Record a video of the screen.
|
||||
-g, --gif Record a video and convert it to the gif format.
|
||||
|
||||
CAPTURE OPTIONS
|
||||
-n, --no-cursor Hide the cursor.
|
||||
-d, --display NUM|TYPE Set the selection to a specific display.
|
||||
Can read from an argument or from stdin.
|
||||
Values: number of display, 'active', 'all' (default)
|
||||
|
||||
-s, --screenshot Take a screenshot
|
||||
-m, --video Record a video of the screen
|
||||
-g, --gif Record a video and convert it to the gif format
|
||||
SCREENSHOT OPTIONS
|
||||
-o, --no-opengl Disable OpenGL hardware-accelerated capture.
|
||||
|
||||
VIDEO OPTIONS
|
||||
-c, --countdown NUM Countdown before recording"
|
||||
-c, --countdown NUM Countdown before recording."
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
|
@ -32,6 +58,28 @@ print_version() {
|
|||
exit 0
|
||||
}
|
||||
|
||||
print_displays() {
|
||||
local monitors=$(xrandr | grep -o "[0-9]*x[0-9]*[+-][0-9]*[+-][0-9]*")
|
||||
|
||||
if [[ -z "$monitors" ]]; then
|
||||
echo "gsu: unable to find any displays"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
readarray -t monitors <<< "$monitors"
|
||||
local displays=""
|
||||
|
||||
for ((i = 0; i < ${#monitors[@]}; i++)); do
|
||||
((num = i + 1))
|
||||
displays="${displays}\n${num}: ${monitors[$i]}"
|
||||
done
|
||||
|
||||
displays=$(sed 's/\\n//' <<< $displays)
|
||||
echo -e "$displays"
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
print_not_int() {
|
||||
regex=$(echo "$1" | sed -e "s/^-\{1,2\}//")
|
||||
|
||||
|
|
@ -57,35 +105,92 @@ Valid characters: alphanumeric, dot, slash, underscore, dash."
|
|||
exit 1
|
||||
}
|
||||
|
||||
print_missing_operand() {
|
||||
echo "\
|
||||
gsu: missing operand
|
||||
Try 'gsu --help' for more information."
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
print_missing_deps() {
|
||||
echo "gsu: missing required dependency -- '$1'"
|
||||
local args=""
|
||||
|
||||
for arg in "$@"; do
|
||||
args="$args '$arg'"
|
||||
done
|
||||
|
||||
args=$(sed 's/ //' <<< $args)
|
||||
echo "gsu: missing required dependency(s) -- $args"
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
print_manually_quit() {
|
||||
echo "gsu: manually quit from user action"
|
||||
exit 0
|
||||
exit 1
|
||||
}
|
||||
|
||||
get_args() {
|
||||
local prev_arg=""
|
||||
|
||||
while [[ "$1" ]]; do
|
||||
case "$1" in
|
||||
"-h" | "--help") print_help ;;
|
||||
"-v" | "--version") print_version ;;
|
||||
"-l" | "--list-displays") print_displays ;;
|
||||
"-u" | "--upload") upload="$1" ;;
|
||||
"-d" | "--display") display="$2" ;;
|
||||
|
||||
"--hide")
|
||||
if ! type -p xdotool >/dev/null; then
|
||||
print_missing_deps "xdotool"
|
||||
fi
|
||||
|
||||
hide="$1"
|
||||
;;
|
||||
|
||||
"--terminal")
|
||||
if [[ -z "$GSU_TERM" ]]; then
|
||||
notify "\
|
||||
gsu: \$GSU_TERM is not set
|
||||
Set this variable in '$config_path/config.conf'."
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
terminal_arg="$1"
|
||||
;;
|
||||
|
||||
"--notify") notify_arg="$1" ;;
|
||||
|
||||
"-r" | "--dmenu")
|
||||
if type -p dmenu >/dev/null; then
|
||||
dmenu_type=(dmenu)
|
||||
fi
|
||||
|
||||
if type -p rofi >/dev/null; then
|
||||
dmenu_type=(rofi -dmenu -p "gsu > ")
|
||||
fi
|
||||
|
||||
if [[ -z "$dmenu_type" ]]; then
|
||||
print_missing_deps "dmenu or rofi"
|
||||
else
|
||||
rofi_arg="$1"
|
||||
fi
|
||||
;;
|
||||
|
||||
"-s" | "--screenshot") set_type "screenshot" ;;
|
||||
"-m" | "--video") set_type "video" ;;
|
||||
"-g" | "--gif") set_type "gif" ;;
|
||||
"-n" | "--nocursor") nocursor="-u"; draw_mouse="-draw_mouse 0" ;;
|
||||
"-n" | "--no-cursor") nocursor="-u"; draw_mouse="-draw_mouse 0" ;;
|
||||
|
||||
"-d" | "--display")
|
||||
if [[ -t 0 ]]; then
|
||||
display="$2"
|
||||
else
|
||||
display=$(cat)
|
||||
display="${display:0:1}"
|
||||
|
||||
if [[ -z "$display" ]]; then
|
||||
notify "gsu: display is empty, assuming quit from dmenu or rofi"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
"-o" | "--no-opengl") noopengl="--noopengl" ;;
|
||||
|
||||
"-c" | "--countdown")
|
||||
if ! [[ $2 =~ ^[0-9]+$ ]]; then
|
||||
|
|
@ -98,20 +203,22 @@ get_args() {
|
|||
-*) print_invalid_option "$1" ;;
|
||||
|
||||
*)
|
||||
if [[ "$1" =~ ^[a-zA-Z0-9_.\/-]+$ ]]; then
|
||||
operand="$1"
|
||||
else
|
||||
print_invalid_operand "$1"
|
||||
fi
|
||||
case "$prev_arg" in
|
||||
"-d" | "--display" | "-c" | "--countdown") ;;
|
||||
*)
|
||||
if [[ "$1" =~ ^[a-zA-Z0-9_.\/-]+$ ]]; then
|
||||
operand="$1"
|
||||
else
|
||||
print_invalid_operand "$1"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
prev_arg="$1"
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -z "$operand" ]]; then
|
||||
print_missing_operand
|
||||
fi
|
||||
}
|
||||
|
||||
get_config() {
|
||||
|
|
@ -206,17 +313,19 @@ get_command() {
|
|||
done
|
||||
|
||||
if [[ "$MONW" == "0" ]] && [[ "$MONH" == "0" ]] && [[ "$MONX" == "0" ]] && [[ "$MONY" == "0" ]]; then
|
||||
echo "gsu: unable to find your display"
|
||||
notify "gsu: unable to find your display"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
check_minimize
|
||||
|
||||
case "$type" in
|
||||
"screenshot")
|
||||
if [[ -z "$display" ]]; then
|
||||
cmd="$(maim $nocursor -s "$operand" 2>&1>/dev/null)"
|
||||
cmd="$(maim $noopengl $nocursor -s "$operand" 2>&1>/dev/null)"
|
||||
else
|
||||
cmd="$(maim $nocursor -g "${MONW}x${MONH}+${MONX}+${MONY}" "$operand" 2>&1>/dev/null)"
|
||||
cmd="$(maim $noopengl $nocursor -g "${MONW}x${MONH}+${MONX}+${MONY}" "$operand" 2>&1>/dev/null)"
|
||||
fi
|
||||
;;
|
||||
|
||||
|
|
@ -225,23 +334,41 @@ get_command() {
|
|||
read -r X Y W H G ID < <(slop -f "%x %y %w %h %g %i")
|
||||
|
||||
if [[ -z "$X" ]] || [[ -z "$Y" ]] || [[ -z "$W" ]] || [[ -z "$H" ]]; then
|
||||
check_maximize
|
||||
print_manually_quit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "$AUDIO" ]]; then
|
||||
if ! type -p pulseaudio >/dev/null; then
|
||||
notify "\
|
||||
gsu: no audio device set, default device 'pulse' cannot be found
|
||||
Either install pulseaudio, or add your audio device to `$config_path/config.conf`."
|
||||
check_maximize
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
AUDIO="pulse"
|
||||
fi
|
||||
|
||||
if [[ ! -z "$countdown_enable" ]]; then
|
||||
check_maximize
|
||||
countdown "$countdown_enable" "Handing control over to ffmpeg in COUNTNUM seconds."
|
||||
check_minimize
|
||||
fi
|
||||
|
||||
echo "Press [q] or [Ctrl+C] to stop recording."
|
||||
|
||||
if [[ -z "$display" ]]; then
|
||||
cmd=$(ffmpeg -y -f alsa -i pulse -r 30 -f x11grab -show_region 1 $draw_mouse -s "$W"x"$H" -i :0.0+$X,$Y -c:v libx264 -crf 18 -preset:v ultrafast -c:a aac -b:a 192k -loglevel error "$output" 2>&1>/dev/null)
|
||||
cmd=$(ffmpeg -y -f alsa -i $AUDIO -r 30 -f x11grab -show_region 1 $draw_mouse -s "$W"x"$H" -i :0.0+$X,$Y -c:v libx264 -crf 18 -preset:v ultrafast -c:a aac -b:a 192k -loglevel error "$output" 2>&1>/dev/null)
|
||||
else
|
||||
cmd=$(ffmpeg -y -f alsa -i pulse -r 30 -f x11grab -show_region 1 $draw_mouse -s "$MONW"x"$MONH" -i :0.0+$MONX,$MONY -c:v libx264 -crf 18 -preset:v ultrafast -c:a aac -b:a 192k -loglevel error "$output" 2>&1>/dev/null)
|
||||
cmd=$(ffmpeg -y -f alsa -i $AUDIO -r 30 -f x11grab -show_region 1 $draw_mouse -s "$MONW"x"$MONH" -i :0.0+$MONX,$MONY -c:v libx264 -crf 18 -preset:v ultrafast -c:a aac -b:a 192k -loglevel error "$output" 2>&1>/dev/null)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
check_maximize
|
||||
}
|
||||
|
||||
set_type() {
|
||||
|
|
@ -250,6 +377,20 @@ set_type() {
|
|||
fi
|
||||
}
|
||||
|
||||
check_minimize() {
|
||||
if [[ ! -z "$hide" ]]; then
|
||||
xdotool_id=$(xdotool getactivewindow)
|
||||
xdotool windowminimize $xdotool_id
|
||||
sleep 0.5
|
||||
fi
|
||||
}
|
||||
|
||||
check_maximize() {
|
||||
if [[ ! -z "$hide" ]] && [[ ! -z "$xdotool_id" ]]; then
|
||||
xdotool windowactivate $xdotool_id
|
||||
fi
|
||||
}
|
||||
|
||||
countdown() {
|
||||
for ((i = $1; i > 0; i--)); do
|
||||
echo -ne "\r${2//COUNTNUM/$i}"
|
||||
|
|
@ -279,7 +420,7 @@ check_valid_exts() {
|
|||
fi
|
||||
done
|
||||
|
||||
echo "gsu: invalid $type file extension -- '$extension'"
|
||||
notify "gsu: invalid $type file extension -- '$extension'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
|
@ -297,8 +438,9 @@ take_screenshot() {
|
|||
|
||||
log "$cmd"
|
||||
|
||||
echo "gsu: maim returned an error"
|
||||
echo "Check the most recent log in '$config_path/logs'."
|
||||
notify "\
|
||||
gsu: maim returned an error
|
||||
Check the most recent log in '$config_path/logs'."
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -326,8 +468,9 @@ take_video() {
|
|||
else
|
||||
log "$cmd"
|
||||
|
||||
echo -e "\ngsu: ffmpeg returned an error"
|
||||
echo "Check the most recent log in '$config_path/logs'."
|
||||
notify "\
|
||||
gsu: ffmpeg returned an error
|
||||
Check the most recent log in '$config_path/logs'."
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -351,8 +494,9 @@ make_gif() {
|
|||
|
||||
log "$cmd"
|
||||
|
||||
echo -e "\ngsu: ffmpeg returned an error"
|
||||
echo "Check the most recent log in '$config_path/logs'."
|
||||
notify "\
|
||||
gsu: ffmpeg returned an error
|
||||
Check the most recent log in '$config_path/logs'."
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
|
@ -380,8 +524,9 @@ upload() {
|
|||
"video")
|
||||
if [[ -z "$V_UPLOAD" ]]; then
|
||||
if [[ -z "$STREAMABLE_USER" ]] || [[ -z "$STREAMABLE_PASS" ]]; then
|
||||
echo -e "\ngsu: invalid streamable credentials"
|
||||
echo "Fill in your credentials in '$config_path/config.conf' and try again."
|
||||
notify "\
|
||||
gsu: invalid streamable credentials
|
||||
Fill in your credentials in '$config_path/config.conf' and try again."
|
||||
|
||||
exit 1
|
||||
else
|
||||
|
|
@ -408,14 +553,14 @@ upload() {
|
|||
rm "$output"
|
||||
|
||||
if [[ "$cmd" == "200" ]]; then
|
||||
echo "Gfycat is processing..."
|
||||
echo "Gfycat is processing..."
|
||||
local count=0
|
||||
|
||||
while [[ "$(curl -s https://api.gfycat.com/v1/gfycats/fetch/status/$output | jq -e -r '.task')" != "complete" ]]; do
|
||||
((count++))
|
||||
|
||||
if [[ $count == 300 ]]; then
|
||||
echo -e "\ngsu: gfycat timed out while processing"
|
||||
notify "gsu: gfycat timed out while processing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -424,7 +569,7 @@ upload() {
|
|||
|
||||
cmd="https://gfycat.com/$output"
|
||||
else
|
||||
echo -e "\ngsu: gfycat returned an invalid http code -- '$cmd'"
|
||||
notify "gsu: gfycat returned an invalid http code -- '$cmd'"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
|
@ -434,48 +579,103 @@ upload() {
|
|||
;;
|
||||
esac
|
||||
|
||||
if type -p xclip >/dev/null && [[ "$cmd" == "http"* ]]; then
|
||||
echo -n "$cmd" | xclip
|
||||
echo -n "$cmd" | xclip -sel clip
|
||||
if type -p xsel >/dev/null && [[ "$cmd" == "http"* ]]; then
|
||||
echo -n "$cmd" | xsel -ib
|
||||
fi
|
||||
|
||||
echo "$cmd"
|
||||
notify "$cmd"
|
||||
}
|
||||
|
||||
remove_args() {
|
||||
local args=()
|
||||
|
||||
while [[ "$1" ]]; do
|
||||
if [[ "$1" == "--terminal" ]]; then
|
||||
shift
|
||||
else
|
||||
args+=("$1")
|
||||
shift
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${args[@]}"
|
||||
}
|
||||
|
||||
main() {
|
||||
get_config
|
||||
get_args "$@"
|
||||
set_type "screenshot"
|
||||
|
||||
case "$type" in
|
||||
"screenshot")
|
||||
if [[ -z "$S_UPLOAD" ]]; then
|
||||
check_valid_exts "png,jpg"
|
||||
if [[ -z "$terminal_arg" ]]; then
|
||||
if [[ ! -z "$rofi_arg" ]]; then
|
||||
case $(echo -e "Take a screenshot\nRecord a video\nRecord a video and convert it to the gif format" | "${dmenu_type[@]}") in
|
||||
"Take a screenshot") set_type "screenshot" ;;
|
||||
"Record a video") set_type "video" ;;
|
||||
"Record a video and convert it to the gif format") set_type "gif" ;;
|
||||
*) print_manually_quit ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
set_type "screenshot"
|
||||
|
||||
if [[ -z "$operand" ]]; then
|
||||
local ext=""
|
||||
|
||||
case "$type" in
|
||||
"screenshot") ext=".png" ;;
|
||||
"video") ext=".mp4" ;;
|
||||
"gif") ext=".gif" ;;
|
||||
esac
|
||||
|
||||
mkdir -p "$config_path/imgs"
|
||||
operand="$config_path/imgs/$(date +"%F.%H-%M-%S.%N")$ext"
|
||||
fi
|
||||
|
||||
case "$type" in
|
||||
"screenshot")
|
||||
if [[ -z "$S_UPLOAD" ]]; then
|
||||
check_valid_exts "png,jpg"
|
||||
fi
|
||||
|
||||
take_screenshot
|
||||
;;
|
||||
|
||||
"video")
|
||||
if [[ -z "$V_UPLOAD" ]]; then
|
||||
check_valid_exts "mp4,mkv,mov"
|
||||
fi
|
||||
|
||||
take_video
|
||||
;;
|
||||
|
||||
"gif")
|
||||
if [[ -z "$G_UPLOAD" ]]; then
|
||||
check_valid_exts "gif"
|
||||
fi
|
||||
|
||||
take_video
|
||||
make_gif
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ ! -z "$upload" ]]; then
|
||||
upload
|
||||
else
|
||||
notify "gsu: saved to '$operand'"
|
||||
fi
|
||||
else
|
||||
pushd $(dirname ${BASH_SOURCE[0]}) &>/dev/null
|
||||
local absolute="$PWD/$(basename ${BASH_SOURCE[0]})"
|
||||
popd &>/dev/null
|
||||
|
||||
local args=$(remove_args "$@")
|
||||
|
||||
for ((i = 0; i < ${#GSU_TERM[@]}; i++)); do
|
||||
if [[ "${GSU_TERM[$i]}" == *"CMD"* ]]; then
|
||||
GSU_TERM[$i]="${GSU_TERM[$i]//CMD/$absolute $args}"
|
||||
fi
|
||||
done
|
||||
|
||||
take_screenshot
|
||||
;;
|
||||
|
||||
"video")
|
||||
if [[ -z "$V_UPLOAD" ]]; then
|
||||
check_valid_exts "mp4,mkv,mov"
|
||||
fi
|
||||
|
||||
take_video
|
||||
;;
|
||||
|
||||
"gif")
|
||||
if [[ -z "$G_UPLOAD" ]]; then
|
||||
check_valid_exts "gif"
|
||||
fi
|
||||
|
||||
take_video
|
||||
make_gif
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ ! -z "$upload" ]]; then
|
||||
upload
|
||||
eval "${GSU_TERM[@]}"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
66
gsu.1
66
gsu.1
|
|
@ -1,44 +1,76 @@
|
|||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.4.
|
||||
.TH GSU "1" "September 2017" "gsu 1.1.1" "User Commands"
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.11.
|
||||
.TH GSU "1" "December 2019" "gsu 1.3.2" "User Commands"
|
||||
.SH NAME
|
||||
gsu \- manual page for gsu 1.1.1
|
||||
gsu \- manual page for gsu 1.3.2
|
||||
.SH SYNOPSIS
|
||||
.B gsu
|
||||
[\fI\,OPTION\/\fR]... \fI\,SOURCE\/\fR
|
||||
.SH DESCRIPTION
|
||||
A general screenshot and upload utility for images, video, and gifs.
|
||||
.PP
|
||||
SOURCE defaults to \fI\,$XDG_CONFIG_HOME/gsu/imgs\/\fP if nothing is provided.
|
||||
The most common location for $XDG_CONFIG_HOME is ~/.config.
|
||||
.PP
|
||||
GENERAL OPTIONS
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Show the help menu
|
||||
Show the help menu.
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-version\fR
|
||||
Show the current version
|
||||
Show the current version.
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-list\-displays\fR
|
||||
List your current displays and their resolutions.
|
||||
.TP
|
||||
\fB\-u\fR, \fB\-\-upload\fR
|
||||
Upload after running the utility
|
||||
Upload after running the utility.
|
||||
.TP
|
||||
\fB\-n\fR, \fB\-\-nocursor\fR
|
||||
Hide the cursor
|
||||
\fB\-\-terminal\fR
|
||||
Open interactive commands in a new terminal..
|
||||
SET THIS IF RUNNING FROM ANYTHING OTHER THAN A TERM,
|
||||
i.e. xbindkeys
|
||||
.TP
|
||||
\fB\-\-hide\fR
|
||||
Minimize the current window while capturing.
|
||||
This is useful when running with \fB\-\-terminal\fR to hide
|
||||
the newly opened term.
|
||||
.TP
|
||||
\fB\-\-notify\fR
|
||||
Send a libnotify notification of the output.
|
||||
.PP
|
||||
UTILITY OPTIONS
|
||||
.TP
|
||||
\fB\-r\fR, \fB\-\-dmenu\fR
|
||||
Select the one of the below options from dmenu or rofi.
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-screenshot\fR
|
||||
Take a screenshot. (default)
|
||||
.TP
|
||||
\fB\-m\fR, \fB\-\-video\fR
|
||||
Record a video of the screen.
|
||||
.TP
|
||||
\fB\-g\fR, \fB\-\-gif\fR
|
||||
Record a video and convert it to the gif format.
|
||||
.PP
|
||||
CAPTURE OPTIONS
|
||||
.TP
|
||||
\fB\-n\fR, \fB\-\-no\-cursor\fR
|
||||
Hide the cursor.
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-display\fR NUM|TYPE
|
||||
Set the selection to a specific display.
|
||||
Can read from an argument or from stdin.
|
||||
Values: number of display, 'active', 'all' (default)
|
||||
.PP
|
||||
SCREENSHOT OPTIONS
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-screenshot\fR
|
||||
Take a screenshot
|
||||
.TP
|
||||
\fB\-m\fR, \fB\-\-video\fR
|
||||
Record a video of the screen
|
||||
.TP
|
||||
\fB\-g\fR, \fB\-\-gif\fR
|
||||
Record a video and convert it to the gif format
|
||||
\fB\-o\fR, \fB\-\-no\-opengl\fR
|
||||
Disable OpenGL hardware\-accelerated capture.
|
||||
.PP
|
||||
VIDEO OPTIONS
|
||||
.TP
|
||||
\fB\-c\fR, \fB\-\-countdown\fR NUM
|
||||
Countdown before recording
|
||||
Countdown before recording.
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B gsu
|
||||
|
|
|
|||
Loading…
Reference in a new issue