Refactored scrot.sh and added secondary display capture
This commit is contained in:
parent
4b6d90efc6
commit
4bd4743f95
2 changed files with 66 additions and 31 deletions
|
@ -7,54 +7,63 @@
|
|||
# - imagemagick: for custom resolution sizes
|
||||
# - mpv: plays audio file upon completion
|
||||
# - boop.sh: uploads screenshot to boop.icu
|
||||
# - Checks for SCREENSHOT_DIR environment variable
|
||||
#
|
||||
# Example global keybinds:
|
||||
#
|
||||
# TYPE CMD KEYBIND
|
||||
# TYPE CMD KEYBIND
|
||||
#
|
||||
# Fullscreen scrot.sh Print
|
||||
# Main monitor scrot.sh -m Meta+Ctrl+Print
|
||||
# Active window/Selct scrot.sh -s Meta+Print
|
||||
# Fullscreen scrot.sh Print
|
||||
# Main monitor scrot.sh --main Meta+Ctrl+Print
|
||||
# Active window/Select scrot.sh --select Meta+Print
|
||||
#
|
||||
# TODO: Autodetect mpv and boop.sh to make them optional
|
||||
# TODO: Figure out how to capture a specific monitor, not just main
|
||||
# TODO: Remove hardcoded shutter sound path
|
||||
|
||||
source ~/.profile # Workaround
|
||||
source ~/.profile # Workaround to avoid using /bin/bash
|
||||
|
||||
# Checks for SCREENSHOT_DIR environment variable
|
||||
#screendir="$HOME/Screenshots"
|
||||
# Edit these to fit setup
|
||||
sound="$HOME/Projects/local-bin/sounds/shutter.ogg"
|
||||
filename="$(date +'%Y%m%d_%H%M%S').png"
|
||||
resolution="1920x1080"
|
||||
|
||||
# For desktop multi-monitor
|
||||
if [[ ${1} == "-d" ]]; then
|
||||
resolution="1920x1590"
|
||||
fi
|
||||
|
||||
args="-m 9 -u"
|
||||
|
||||
main_res="1920x1080+0+510"
|
||||
secondary_res="1080x1920+1920+0"
|
||||
|
||||
# Ensure screenshot directory is there so the script will work
|
||||
if [[ ! -d $SCREENSHOT_DIR ]]; then
|
||||
mkdir -p $SCREENSHOT_DIR
|
||||
fi
|
||||
|
||||
echo "Entering $SCREENSHOT_DIR"
|
||||
cd $SCREENSHOT_DIR
|
||||
|
||||
if [[ ${1} == "-m" ]]; then
|
||||
args="${args} -g ${resolution}+0+510" # for standard 1080p single monitor
|
||||
else
|
||||
args="${args}"
|
||||
# Setup is 1920x1590: main = 1920x1080; secondary = 1080x1920
|
||||
if [[ ${1} == "--main" ]]; then
|
||||
resolution=$main_res
|
||||
elif [[ ${1} == "--secondary" ]]; then
|
||||
resolution=$secondary_res
|
||||
fi
|
||||
|
||||
# Set maim arguments based on command arguments
|
||||
args="-m 9 -u"
|
||||
if [[ ${1} == "--select" ]]; then
|
||||
args="$args ${1}"
|
||||
elif [[ ${1} == "--main" || ${1} == "--secondary" ]]; then
|
||||
args="$args -g $resolution"
|
||||
|
||||
fi
|
||||
|
||||
# Take the screenshot with maim
|
||||
maim -B $args $filename > /dev/null 2>&1
|
||||
|
||||
# cleanup for my dual-monitor setup
|
||||
if [[ ${1} == "-d" ]]; then
|
||||
# cleanup for main monitor
|
||||
if [[ ${1} == "--main" ]]; then
|
||||
magick convert $filename -trim +repage $SCREENSHOT_DIR/$filename
|
||||
fi
|
||||
|
||||
mpv $sound
|
||||
$HOME/.local/bin/boop.sh "$SCREENSHOT_DIR/$filename"
|
||||
# Play sound if mpv is available
|
||||
if [[ -n "$(which mpv)" ]]; then
|
||||
mpv $sound
|
||||
fi
|
||||
|
||||
# Upload to boop if boop.sh is available
|
||||
if [[ -n "$(which boop.sh)" ]]; then
|
||||
boop.sh "$SCREENSHOT_DIR/$filename"
|
||||
fi
|
||||
|
|
|
@ -3,7 +3,7 @@ DataCount=1
|
|||
|
||||
[Data_1]
|
||||
Comment=Comment
|
||||
DataCount=3
|
||||
DataCount=4
|
||||
Enabled=true
|
||||
Name=Scrot.sh
|
||||
SystemGroup=0
|
||||
|
@ -49,7 +49,7 @@ Type=SIMPLE_ACTION_DATA
|
|||
ActionsCount=1
|
||||
|
||||
[Data_1_2Actions0]
|
||||
CommandURL=/home/siina/.local/bin/scrot.sh -m
|
||||
CommandURL=/home/siina/.local/bin/scrot.sh --main
|
||||
Type=COMMAND_URL
|
||||
|
||||
[Data_1_2Conditions]
|
||||
|
@ -61,7 +61,7 @@ Comment=Simple_action
|
|||
TriggersCount=1
|
||||
|
||||
[Data_1_2Triggers0]
|
||||
Key=
|
||||
Key=Meta+Ctrl+Print
|
||||
Type=SHORTCUT
|
||||
Uuid={c339b929-b41c-4c59-928e-2fafe008b001}
|
||||
|
||||
|
@ -75,7 +75,7 @@ Type=SIMPLE_ACTION_DATA
|
|||
ActionsCount=1
|
||||
|
||||
[Data_1_3Actions0]
|
||||
CommandURL=/home/siina/.local/bin/scrot.sh -s
|
||||
CommandURL=/home/siina/.local/bin/scrot.sh --select
|
||||
Type=COMMAND_URL
|
||||
|
||||
[Data_1_3Conditions]
|
||||
|
@ -91,6 +91,32 @@ Key=Meta+Print
|
|||
Type=SHORTCUT
|
||||
Uuid={205c92eb-bb7b-47a2-8309-b9ebf3f655e2}
|
||||
|
||||
[Data_1_4]
|
||||
Comment=Comment
|
||||
Enabled=true
|
||||
Name=Secondary Display
|
||||
Type=SIMPLE_ACTION_DATA
|
||||
|
||||
[Data_1_4Actions]
|
||||
ActionsCount=1
|
||||
|
||||
[Data_1_4Actions0]
|
||||
CommandURL=/home/siina/.local/bin/scrot.sh --secondary
|
||||
Type=COMMAND_URL
|
||||
|
||||
[Data_1_4Conditions]
|
||||
Comment=
|
||||
ConditionsCount=0
|
||||
|
||||
[Data_1_4Triggers]
|
||||
Comment=Simple_action
|
||||
TriggersCount=1
|
||||
|
||||
[Data_1_4Triggers0]
|
||||
Key=
|
||||
Type=SHORTCUT
|
||||
Uuid={3069937f-c0f2-4741-96a0-ca47d3f123f0}
|
||||
|
||||
[Main]
|
||||
AllowMerge=false
|
||||
Version=2
|
||||
|
|
Loading…
Reference in a new issue