From 2ee44a5f1533ee4dc67a28f10359ff6f730589cc Mon Sep 17 00:00:00 2001 From: sheldonmlee Date: Sun, 23 May 2021 14:30:50 +0800 Subject: [PATCH] Moved all GUI related scripts to wm_scripts. --- .config/wm_scripts/manpages.sh | 8 +++ .config/wm_scripts/screenshot.sh | 109 +++++++++++++++++++++++-------- .custom_bash_scripts | 26 +------- 3 files changed, 91 insertions(+), 52 deletions(-) create mode 100755 .config/wm_scripts/manpages.sh diff --git a/.config/wm_scripts/manpages.sh b/.config/wm_scripts/manpages.sh new file mode 100755 index 0000000..fe09af9 --- /dev/null +++ b/.config/wm_scripts/manpages.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# +# Views manpages as pdf. +# + +name=$(man -k . | rofi -dmenu | awk '{print($1)}') +[[ ! -z $name ]] && man -Tpdf $name | zathura - diff --git a/.config/wm_scripts/screenshot.sh b/.config/wm_scripts/screenshot.sh index 1a4c73f..bc88583 100755 --- a/.config/wm_scripts/screenshot.sh +++ b/.config/wm_scripts/screenshot.sh @@ -1,34 +1,89 @@ #!/bin/bash -#dmenu script for screenshots -CUSTOM_SCRIPTS_FILE=~/.custom_bash_scripts -if test -f $CUSTOM_SCRIPTS_FILE; then - source $CUSTOM_SCRIPTS_FILE -else - echo ".custom_bash_scripts.sh does not exist." -fi -options=" +# +# Script to take screenshots or gifs +# + +scrot_dir=$HOME/screenshots +gif_dir=$scrot_dir/gifs +date_format='%Y-%m-%d_%H-%M-%S' +[ -d $scrot_dir ] || mkdir $scrot_dir +[ -d $gif_dir ] || mkdir $gif_dir + +main() { + prompt_main +} + +# prompt with rofi +prompt_main() { + options=" 1) Fullscreen\n\ 2) Selection\n\ -3) Record screen\n\ -" -#echo -e $options +3) Record screen + " + #echo -e $options -# -i case insensitive -# -l vertical lines -option=$(echo -e $options | dmenu -i) + # -i case insensitive + # -l vertical lines + option=$(echo -e $options | rofi -dmenu) -#echo "\"$option\"" -case $option in -1*) - sleep 0.5 - f_scrot - ;; -2*) - s_scrot - ;; -2*) - ffmpeg_record - ;; -esac + #echo "\"$option\"" + case $option in + 1*) + sleep 0.5 + f_scrot + ;; + 2*) + s_scrot + ;; + 3*) + prompt_gif + ;; + esac +} +prompt_gif() { + options=" +10s\n\ +30s\n\ +60s + " + option=$(echo -e $options | rofi -dmenu) + + case $option in + 10s) + byzanz_gif 10 + ;; + 30s) + byzanz_gif 30 + ;; + 60s) + byzanz_gif 60 + ;; + esac +} + + +# screenshots using scrot +s_scrot() { + name=$(date +${date_format}_sel.png) + path="${scrot_dir}/${name}" + scrot -s $path & + xclip -sel clip $path -t image/png +} + +f_scrot() { + name=$(date +${date_format}_full.png) + path="${scrot_dir}/${name}" + scrot $path && + xclip -sel clip $path -t image/png +} + +# screen recorder +byzanz_gif() { + name=$(date +${date_format}.gif) + path="${gif_dir}/${name}" + byzanz-record -c -d $1 --delay=0 $path +} + +main "$@" diff --git a/.custom_bash_scripts b/.custom_bash_scripts index 135002c..aa5c042 100644 --- a/.custom_bash_scripts +++ b/.custom_bash_scripts @@ -1,30 +1,5 @@ #!/bin/bash - -# screenshots using scrot -scrot_dir=$HOME/screenshots/ -date_format='%Y-%m-%d_%H-%M-%S' - -s_scrot() { - name=$(date +${date_format}_sel.png) - path="${scrot_dir}${name}" - scrot -s $path - xclip -sel clip $path -t image/png -} - -f_scrot() { - name=$(date +${date_format}_full.png) - path="${scrot_dir}${name}" - scrot $path - xclip -sel clip $path -t image/png -} - -# screen recorder -byzanz_10() { - name=$(date +${date_format}.gif) - byzanz-record -c -d 10 --delay=0 "${scrot_dir}${name}" -} - # cd into config dir cfdir() { @@ -67,3 +42,4 @@ function unrealbuild { ${UNR_PATH}/Engine/Build/BatchFiles/Linux/RunMono.sh ${UNR_PATH}/Engine/Binaries/DotNET/UnrealBuildTool.exe $PROJ_NAME -ModuleWithSuffix $PROJ_NAME Linux Development -editorrecompile -canskiplink "${CURR_DIR}/${PROJ_NAME}.uproject" -progress } +