Author Topic: simple Screenshot script  (Read 1177 times)

0 Members and 1 Guest are viewing this topic.

Offline oberon

  • Core Team
  • *****
  • Posts: 3858
  • I'm nice. Be new!
  • Branch: unstable
  • Desktop: i3, Deepin, Cinnamon
  • GPU Card: Intel ValleyView Gen7
  • GPU driver: Intel
  • Kernel: 4.1 / 4.4
  • Skill: Intermediate
simple Screenshot script
« on: 10. March 2016, 11:38:32 »
I just wrote this little script to be included in the next i3 release.
It uses scrot and can be installed and applied in any environment.
I will package it as i3-scrot.
Quote
available options:
-d | --desk        full screen
-w | --window  active window
-s | --select      selection
-h | --help         display this information

Default option is 'full screen'.

The file destination can be set in ~/.config/i3-scrot.conf
Default is ~/Pictures

It gives feedback via desktop notifications.

Code: [Select]
#!/bin/sh
# /usr/bin/i3-scrot
#
# simple screenshot-script using scrot for manjaro-i3 by oberon@manjaro.org

_conf=$HOME/.config/i3-scrot.conf

if ! [ -f $_conf ]; then
echo "scrot_dir=$(xdg-user-dir PICTURES)" > $_conf
fi

source $_conf

if ! [ -d $scrot_dir ]; then
mkdir -p $scrot_dir
fi

case "$1" in
--desk|-d|$NULL)
cd $scrot_dir
        scrot &&
sleep 1 &&
notify-send "screenshot has been saved in $scrot_dir"
;;
--window|-w)
cd $scrot_dir
scrot -u &&
sleep 1 &&
notify-send "screenshot has been saved in $scrot_dir"
;;
--select|-s)
cd $scrot_dir
notify-send 'select an area for the screenshot' &
scrot -s &&
sleep 1 && notify-send "screenshot has been saved in $scrot_dir"
;;
--help|-h)
echo "
available options:
-d | --desk    full screen
-w | --window  active window
-s | --select  selection
-h | --help    display this information

Default option is 'full screen'.

The file destination can be set in ${_conf}.
Default is $scrot_dir
"
;;
*)
echo "
== ! i3-scrot: missing or wrong argument ! ==

available options:
-d | --desk    full screen
-w | --window  active window
-s | --select  selection
-h | --help    display this information

Default option is 'full screen'.

The file destination can be set in ${_conf}.
Default is $scrot_dir
"

        exit 2
esac

exit 0
« Last Edit: 21. March 2016, 12:08:31 by oberon »
manjaro is addictive ::)
* manjaro-i3  * manjaro-cinnamon  * manjaro-deepin

Offline eugen-b

  • Support Team
  • ****
  • Posts: 3191
  • Branch: testing
  • Desktop: LXDE, Fluxbox, JWM, LXQt, bspwm
  • GPU Card: Intel 82945G/GZ
  • GPU driver: free
  • Kernel: 4.5, 4.6
  • Skill: Intermediate
Re: simple Screenshot script
« Reply #1 on: 21. March 2016, 11:16:37 »
a stupid question, what command does call it, simply i3-scrot? Answer: yes! :-[
« Last Edit: 21. March 2016, 12:06:35 by oberon »
MSI Wind Nettop, Intel Atom 230 1.6GHz (64bit), 2GB RAM
DEs: NET-minimal + (LXDE / Fluxbox / JWM); LXQt OpenRC
how to install on btrfs subvolumes
http://manjaro.github.io/donate/

Offline oberon

  • Core Team
  • *****
  • Posts: 3858
  • I'm nice. Be new!
  • Branch: unstable
  • Desktop: i3, Deepin, Cinnamon
  • GPU Card: Intel ValleyView Gen7
  • GPU driver: Intel
  • Kernel: 4.1 / 4.4
  • Skill: Intermediate
Re: simple Screenshot script
« Reply #2 on: 21. March 2016, 12:11:23 »
 ;D you got it!
manjaro is addictive ::)
* manjaro-i3  * manjaro-cinnamon  * manjaro-deepin