Update the locations, some scripts, and whatnot

This commit is contained in:
foo-dogsquared 2020-04-05 00:27:13 +08:00
parent 05c722ed53
commit 3df3e71c52
9 changed files with 444 additions and 65 deletions

View File

@ -25,6 +25,7 @@ Review the code first, change the setting accordingly, and apply it.
== Screenshots
My setup was made by the FOSS gang.
Take note that the screenshots does not represent the daily look of the desktop since I always change the wallpaper and the colorschemes with https://github.com/dylanaraps/pywal[Pywal].
.bspwm setup with no windows
image::docs/bspwm-empty.png[bspwm setup with no windows]
@ -86,6 +87,8 @@ I've also tried to get the creators to show appreciation for their work.
* https://www.reddit.com/r/wallpapers/comments/co9t14/sand/[`sand.jpg`]
* https://www.artstation.com/artwork/XBlZbY[`scarecrow-field.jpg`]
** Creator: https://www.artstation.com/joejazz[Josef Bartoň]
@ -356,7 +359,7 @@ Pywal is a tool for generating color schemes from an image.
It is mainly used to produce templates for different applications (e.g., Vim, Visual Studio, the tty).
* The config directory is at `wal`.
* The usual target path would be on `~/.local/share/wal`.
* The usual target path would be on `~/.config/wal`.
The target path is more lenient since it only contains data files.
You have more choices here.
* Minimum version (from `wal -v`):

367
bin/rofi-screen Normal file
View File

@ -0,0 +1,367 @@
#!/usr/bin/env bash
# This is a modified script of the original rofi-screenshot script by @ceuk on GitHub.
# This simply removes the ffcast dependency and replaced it with MORE dependencies.
# I did this so I can call this a 'productive' day.
# The original script is in https://github.com/ceuk/rofi-screenshot.
# (Seriously though, ffcast is cool.)
# This script basically creates an applet through Rofi for all of your screenshotting and screencasting needs.
# This script is licensed with Do What The F*ck You Want To Public License (WTFPL).
# Feel free to steal it, copy it, cook it, teach it, marry it, whatever it.
# Dependencies (or at least at the time of updating this script):
# * bash 5.0.16
# * GNU coreutils 8.31
# * ffmpeg 4.2.2 - Mainly for converting files and video capture.
# * maim 5.5.3 - Screen capture tool.
# * dunst 1.4.1 - A desktop notification daemon.
# * xclip 0.13 - X-based clipboard manager.
# * xdg-user-dir 0.17 - Basically lists directory according to the XDG directory standard or smth; this dependency is the least important.
# * util-linux 2.35
# Feel free to change these.
readonly _script_name="$(basename $0)"
readonly screenshots_directory=$(xdg-user-dir PICTURES)
readonly videos_directory=$(xdg-user-dir VIDEOS)
readonly lockfile="/tmp/rofi-screen.lock"
#####################
# UTILITY FUNCTIONS #
#####################
# Toggle running of a program.
# If a process that is stored on a specific file exists, it prompts the user to kill it.
# $1 - The command to run when there is no active processes.
# $2 - The prompt message when the prompt is active.
# $3 - The command to run when the prompt is accepted.
_toggle() {
local cmd="$1"
local prompt_msg="$2"
local prompt_cmd="$3"
if [[ ! -f "$lockfile" ]] && touch "$lockfile";
then
# Delete the lockfile when the script has exited successfully.
trap "rm -f $lockfile" 0
trap "rm -f $lockfile" ERR
$("$cmd")
else
_prompt "$prompt_msg" "$prompt_cmd"
fi
}
_unlock() {
pid="$(cat $lockfile)"
kill -SIGTERM "$pid"
rm -f "$lockfile"
}
# Prompts the user.
# $1 - The prompt message.
# $@ - The command to be executed in case the user agrees.
_prompt() {
local prompt_msg="$1"
shift
[ "$(printf "No\\nYes" | rofi -dmenu -p "$prompt_msg")" = "Yes" ] && "$@"
}
# Converts a video to GIF with ffmpeg.
# $1 - The input file to be converted.
# $2 - The output file.
_video_to_gif() {
local input_file="$1"
local output_file="$2"
ffmpeg -i "$input_file" -vf palettegen -f image2 -c:v png - |
ffmpeg -i "$input_file" -i - -filter_complex paletteuse "$output_file"
}
# It just counts down with desktop notifications.
# $1 - The duration of the countdown.
_countdown() {
local counter="$((${1:-3}))"
local msg="${2:-Countdown}"
while [[ counter -ne 0 ]];
do
notify-send "$msg" "Recording in $counter seconds" --expire-time 1000 --urgency low
sleep 1
counter=$((counter - 1))
done
}
# Prints the screen size dynamically.
_screen_size() {
# We're using xrandr to know the list of available resolutions.
# Conveniently, the current resolution is marked with an asterisk (*).
xrandr | awk '/*/ { print $1 }'
}
# Basically the built-in `wait` command with some additional stuff going on.
# $@ - The command to be executed in the background.
_wait() {
$@ &
local pid=$!
echo $pid >> "$lockfile"
wait $pid
}
# Create a desktop notification and exit.
# This is mostly used for failure messages.
# $1 - Notification header message.
# $2 - Notification body message.
# $3 - Exit code.
_notify_and_exit() {
local notif_header="$1"
local notif_body="$2"
local exit_code="${3:-1}"
notify-send "$notif_header" "$notif_body"
exit $exit_code
}
####################
# COMMAND DEFAULTS #
####################
ffmpeg() {
exec ffmpeg -nostdin "$@"
}
maim() {
exec maim --hidecursor "$@"
}
slop() {
exec slop --highlight --tolerance=0 --color=0.0,0.0,0.0,0.4 "$@"
}
#############
# FUNCTIONS #
#############
# Most of the commands are only specific to my setup.
# Adjust the script to fit with yours, alright?
# Capture region to clipboard.
capture_region_to_clipboard() {
notify-send "Screenshot" "Select a region to capture"
maim -s | xclip -selection clipboard -t image/png
notify-send "Screenshot" "Region copied to Clipboard"
}
# Capture region to file.
# $1 - The output file.
capture_region_to_file() {
file=${1:-"$screenshots_directory/$(date '+%F-%H-%M-%S').png"}
notify-send "Screenshot" "Select a region to capture"
maim -s "$file"
notify-send "Screenshot" "File saved to $file"
}
# Capture screen to clipboard.
capture_screen_to_clipboard() {
maim -i $(xdotool getactivewindow) | xclip -selection clipboard -t image/png
notify-send "Screenshot" "Screen image copied to clipboard"
}
# Capture screen to file.
# $1 - The output file. A default value is provided.
capture_screen_to_file() {
file=${1:-"$screenshots_directory/$(date '+%F-%H-%M-%S-screen').png"}
maim -i $(xdotool getactivewindow) "$file"
notify-send "Screenshot" "Screen image saved to $file"
}
# Unlike screenshot functions, screencast functions check for another instance of it running.
# If there is another instance of recording, the user will be prompted to kill it before recording a new one.
# Record a region to a video file.
# $1 - The path of the output.
record_region_to_mkv() {
notify-send "Screen cast" "Select a region to record"
# Storing all of the relevant data.
# We're separating the declaration and the initialization since it expands to the exit status.
local region;
region=$(slop -f "%x %y %w %h %g %i") || _notify_and_exit "Screen capture failed" "Selection mode has been exited. Cancelling the recording."
read -r pos_x pos_y width height grid id <<< "$region"
# Setting the file name.
local file=${1:-"$videos_directory/$(date '+%F-%H-%M-%S')-${pos_x}-${pos_y}.mkv"}
# Notifying the user about the ongoing recording session.
_countdown
notify-send "Screen cast" "Selected region currently recording. To be saved at $file"
# Executing the recording process in the background and waiting for it.
_wait ffmpeg -f x11grab -s "${width}x${height}" -i ":0.0+${pos_x},${pos_y}" -f pulse -ac 2 -i default "$file"
# And notifying the user about the new video file.
notify-send "Screen cast" "Recording saved to $file"
}
# Record video to screen.
# $1 - The path to the output file.
# Will default to the $videos_directory
record_screen_to_mkv() {
# Setting the file name.
local file=${1:-"$videos_directory/$(date '+%F-%H-%M-%S')-$(_screen_size).mkv"}
# Just notifying the user about the recording session.
_countdown
notify-send "Screen cast" "Screen currently recording. To be saved at $file"
# Executing the recording process in the background and waiting for it.
_wait ffmpeg -f x11grab -s "$(_screen_size)" -i ":0.0+0+0" "$file"
# And notifying the user about the new video file.
notify-send "Screen cast" "Recording saved to $file"
}
# Record region to GIF file.
# $1 - The output file.
record_region_to_gif() {
# It is more recommended to have the live recording file that is not MP4.
# In my tests, MP4 files have more chances to fail than other formats so we'll change the format to MKV.
local temp_screencast="/tmp/screenshot_gif.mkv"
record_region_to_mkv $temp_screencast
notify-send "Screenshot" "Converting to gif... (this can take a while)"
_video_to_gif "$temp_screencast" "$file" \
&& notify-send "Screen cast" "Recording saved to $file" \
|| _notify_and_exit "Screen cast has failed to be converted" "Some things go like that, I guess..."
rm "$temp_screencast" 2>/dev/null
}
# Record screen to GIF file.
# $1 - The location of the output file.
record_screen_to_gif() {
local readonly temp_screencast="/tmp/screenshot_gif.mkv"
record_screen_to_mkv $temp_screencast
notify-send "Screenshot" "Converting to gif... (this can take a while)"
_video_to_gif $temp_screencast "$screenshot_directory/$dt.gif"
rm $temp_screencast
notify-send "Screenshot" "Recording saved to $screenshot_directory"
}
_get_options() {
echo " Capture Region  Clip"
echo " Capture Region  File"
echo " Capture Screen  Clip"
echo " Capture Screen  File"
echo " Record Region  File (GIF)"
echo " Record Screen  File (GIF)"
echo " Record Region  File (MKV)"
echo " Record Screen  File (MKV)"
}
# Simply checks if the given script is available.
# $1 - The script to be checked.
_check_deps() {
local script=$1
if ! hash $script 2>/dev/null; then
echo "Error: This script requires $script"
exit 1
fi
}
# The help section string.
_help="Usage: $_script_name [OPTIONS]
Launches a menu for your screenshoting and screencasting needs.
Options:
-h, --help Prints the help section.
--stop Stop if there's an active process.
--check Exits successfully if there's an active process.
--prompt Prompts if there's an active process.
"
main() {
# Check the dependencies.
# I think this is a bit overkill, I'll probably refactor this later on.
_check_deps xdg-user-dir
_check_deps xclip
_check_deps slop
_check_deps dunst
_check_deps maim
_check_deps ffmpeg
_check_deps rofi
# Parsing the arguments.
# Since getopts does not support long options so we'll have to roll our own.
while [[ $# -gt 0 ]];
do
case $1 in
-h|--help)
printf "$_help" && exit 0
;;
--stop)
set -e
_unlock
exit 0
;;
--check)
[[ -f "$lockfile" ]] || exit 1
exit 0
;;
--prompt)
[[ -f "$lockfile" ]] && _prompt "Cancel the active process?" _unlock || exit 1
exit 0
esac
done
# Get choice from rofi
choice=$( (_get_options) | rofi -theme fds-sidebar-dark -dmenu -i -fuzzy -p "Choose your action" )
# If user has not picked anything, exit
if [[ -z "${choice// }" ]]; then
exit 1
fi
# run the selected command
case $choice in
' Capture Region  Clip')
capture_region_to_clipboard
;;
' Capture Region  File')
capture_region_to_file
;;
' Capture Screen  Clip')
capture_screen_to_clipboard
;;
' Capture Screen  File')
capture_screen_to_file
;;
' Record Region  File (GIF)')
_toggle record_region_to_gif "Cancel the recording?" _unlock
;;
' Record Screen  File (GIF)')
_toggle record_screen_to_gif "Cancel the recording?" _unlock
;;
' Record Region  File (MKV)')
_toggle record_region_to_mkv "Cancel the recording?" _unlock
;;
' Record Screen  File (MKV)')
_toggle record_screen_to_mkv "Cancel the recording?" _unlock
;;
esac
}
main $@

View File

@ -9,7 +9,7 @@
"ranger": "$HOME/.config/ranger/",
"rofi": "$HOME/.config/rofi/",
"sxhkd": "$HOME/.config/sxhkd/",
"wal": "$HOME/.local/share/wal",
"wal": "$HOME/.config/wal",
"xorg": "$HOME",
"zsh": "$HOME"
}

View File

@ -9,3 +9,4 @@ reinstall:
.PHONY = clean
clean:
./manager.py --commands "stow --delete {package} --target {location}"

View File

@ -2,10 +2,11 @@
0ad-data a23.1-1
adobe-source-sans-pro-fonts 3.006-1
adobe-source-serif-pro-fonts 3.001-1
alacritty 0.4.1-2
alacritty 0.4.2-1
alex 3.2.5-5
alsa-plugins 1.2.2-1
alsa-utils 1.2.2-1
amd-ucode 20200224.efcfa03-1
amd-ucode 20200316.8eb0b28-1
arandr 0.1.10-4
arc-gtk-theme 20190917-1
arc-icon-theme 20161122-2
@ -14,7 +15,7 @@ asciidoctor 2.0.10-2
audacious 3.10.1-2
audacity 1:2.3.3-2
autoconf 2.69-7
automake 1.16.1-2
automake 1.16.2-1
base 2-2
bash 5.0.016-1
binutils 2.34-2
@ -22,19 +23,22 @@ bison 3.5.3-1
blender 17:2.82.a-1
bspwm 0.9.9-1
bzip2 1.0.8-3
cadence 0.9.1-1
cabal-install 3.0.0.0-72
cadence 0.9.1-2
carla 2.0.0-1
chromium 80.0.3987.149-1
chromium 80.0.3987.163-1
clang 9.0.1-1
code 1.43.2-1
coreutils 8.31-3
code 1.43.2-2
coreutils 8.32-1
cronie 1.5.5-1
cryptsetup 2.3.1-1
device-mapper 2.02.186-5
device-mapper 2.02.187-1
dhall 1.31.1-2
dhall-json 1.6.3-6
dhcpcd 8.1.6-1
diffutils 3.7-3
dmenu 4.9-1
docker 1:19.03.8-1
docker 1:19.03.8-2
dunst 1.4.1-1
e2fsprogs 1.45.6-1
efibootmgr 16-2
@ -46,8 +50,8 @@ feh 3.3-2
file 5.38-3
filesystem 2019.10-2
findutils 4.7.0-2
firefox 74.0-2
firefox-developer-edition 75.0b9-1
firefox 74.0.1-1
firefox-developer-edition 75.0b11-1
flex 2.6.4-3
freeciv 2.6.2-1
freeglut 3.2.1-1
@ -56,7 +60,8 @@ gcc 9.3.0-1
gcc-libs 9.3.0-1
gdb 9.1-2
gettext 0.20.1-3
gimp 2.10.18-4
ghc 8.8.3-1
gimp 2.10.18-5
gimp-help-en 2.10.0-1
git 2.26.0-1
glava 1.6.3-1
@ -67,15 +72,17 @@ gource 0.51-2
graphviz 2.42.3-3
grep 3.4-1
groff 1.22.4-3
gvfs 1.44.0-1
gucharmap 13.0.0-1
gvfs 1.44.1-1
gzip 1.10-3
happy 1.19.12-4
htop 2.2.0-3
hugo 0.68.3-1
i3-gaps 4.18-1
i3blocks 1.5-3
i3status 2.13-2
inetutils 1.9.4-8
inkscape 0.92.4-14
inkscape 0.92.4-15
iproute2 5.5.0-1
iputils 20190709-2
jack2 1.9.14-1
@ -86,36 +93,37 @@ jre-openjdk 13.0.2.u8-1
keybase 5.3.0-1
kicad 5.1.5-1
kicad-library 5.1.5-1
krita 4.2.9-1
krita 4.2.9-2
less 551-3
libtool 2.4.6+42+gb88cebd5-11
licenses 20191011-2
linux 5.5.13.arch1-1
linux-firmware 20200224.efcfa03-1
linux 5.5.13.arch2-1
linux-firmware 20200316.8eb0b28-1
lldb 9.0.1-1
llvm 9.0.1-2
lmms 1.2.1-3
logrotate 3.16.0-1
lolcat 100.0.0-2
lvm2 2.02.186-5
lvm2 2.02.187-1
lxappearance 0.6.3-2
lxsession 1:0.5.5-1
m4 1.4.18-3
maim 5.5.3-2
make 4.3-1
man-db 2.9.1-1
man-db 2.9.1-2
man-pages 5.05-2
mdadm 4.1-2
moreutils 0.63-1
mpg123 1.25.13-1
musescore 3.4.2-1
nano 4.8-1
nano 4.9.1-1
ncmpcpp 0.8.2-11
neofetch 7.0.0-1
neovim 0.4.3-2
netctl 1.20-2
netctl 1.21-2
networkmanager 1.22.10-1
nnn 3.0-1
nodejs 13.11.0-1
nodejs 13.12.0-1
noto-fonts 20190926-4
noto-fonts-emoji 20191016-6
npm 6.14.4-1
@ -128,11 +136,11 @@ p7zip 16.02-5
pacman 5.2.1-4
pacman-contrib 1.3.0-1
pamixer 1.4-3
pandoc 2.9.2-73
pandoc 2.9.2.1-8
patch 2.7.6-8
pavucontrol 1:4.0-1
pciutils 3.6.4-1
perl 5.30.1-1
perl 5.30.2-1
php 7.4.4-1
picom 7.5-3
pkgconf 1.6.3-3
@ -146,35 +154,39 @@ pulseaudio-jack 13.0-3
pulsemixer 1.5.0-2
pv 1.6.6-2
python-pip 20.0.2-1
python-pynvim 0.4.1-1
python-pywal 3.3.0-2
python2-scour 0.37-4
qbittorrent 4.2.1-1
qbittorrent 4.2.2-1
qrencode 4.0.2-1
qt5-script 5.14.1-1
qt5-script 5.14.2-1
r 3.6.3-1
racket 7.5-1
ranger 1.9.3-1
reiserfsprogs 3.6.27-3
rofi 1.5.4-1
ruby 2.7.0-1
ruby 2.7.1-1
ruby-rouge 3.14.0-2
s-nail 14.9.17-1
scrot 1.2-1
sed 4.8-1
shadow 4.8.1-1
shotcut 20.02.17-1
sonic-pi 3.2.0-2
shotcut 20.02.17-2
sonic-pi 3.2.1-2
soundfont-fluid 3.1-2
sox 14.4.2-5
stack 2.1.3.20200310-43
stow 2.3.1-2
strace 5.5-1
sudo 1.8.31.p1-1
sxhkd 0.6.1-1
sxiv 26-1
sysfsutils 2.1.0-11
systemd 245.2-2
systemd-sysvcompat 245.2-2
systemd 245.4-2
systemd-sysvcompat 245.4-2
tabbed 0.6-3
tar 1.32-3
telegram-desktop 2.0.1-1
tesseract 4.1.1-1
tesseract-data-eng 1:4.0.0-1
texinfo 6.7-2
@ -190,28 +202,31 @@ thunar-volman 0.9.5-2
thunderbird 68.6.0-1
timidity++ 2.15.0-2
tmux 3.0_a-1
tor 0.4.2.7-1
tree 1.8.0-1
ttf-bitstream-vera 1.10-12
ttf-dejavu 2.37-2
ttf-fira-code 2-1
ttf-font-awesome 5.13.0-1
ttf-ibm-plex 4.0.2-2
ttf-joypixels 5.5.0-2
ttf-joypixels 5.5.0-3
ttf-nerd-fonts-symbols 2.1.0-2
udiskie 2.1.0-1
upx 3.96-2
usbutils 012-2
util-linux 2.35.1-1
vi 1:070224-4
vim 8.2.0343-1
vlc 3.0.8-10
weechat 2.7.1-1
vlc 3.0.8-11
weechat 2.8-1
wget 1.20.3-2
which 2.21-5
xarchiver 0.5.4.14-1
xclip 0.13-2
xdg-user-dirs 0.17-2
xdotool 3.20160805.1-2
xf86-video-vesa 2.4.0-2
xfsprogs 5.4.0-1
xfsprogs 5.5.0-1
xorg-bdftopcf 1.1-1
xorg-docs 1.7.1-2
xorg-font-util 1.3.2-1
@ -221,13 +236,13 @@ xorg-fonts-encodings 1.0.5-1
xorg-iceauth 1.0.8-1
xorg-luit 1.1.1-3
xorg-mkfontscale 1.2.1-2
xorg-server 1.20.7-1
xorg-server-common 1.20.7-1
xorg-server-devel 1.20.7-1
xorg-server-xephyr 1.20.7-1
xorg-server-xnest 1.20.7-1
xorg-server-xvfb 1.20.7-1
xorg-server-xwayland 1.20.7-1
xorg-server 1.20.8-1
xorg-server-common 1.20.8-1
xorg-server-devel 1.20.8-1
xorg-server-xephyr 1.20.8-1
xorg-server-xnest 1.20.8-1
xorg-server-xvfb 1.20.8-1
xorg-server-xwayland 1.20.8-1
xorg-sessreg 1.1.2-1
xorg-setxkbmap 1.3.2-1
xorg-smproxy 1.0.6-2
@ -263,6 +278,6 @@ xorg-xwininfo 1.1.5-1
xorg-xwud 1.0.5-1
youtube-dl 2020.03.24-1
zathura 0.4.5-1
zathura-pdf-mupdf 0.3.5-2
zathura-pdf-mupdf 0.3.5-3
zsh 5.8-1
zsh-completions 0.31.0-1

View File

@ -104,7 +104,7 @@
format-prefix = "MEM"
format-prefix-background = ${colors.memory_module_bg}
format-prefix-foreground = ${colors.foreground}
label = %percentage_used%%
label = %gb_used%
[module/wlan]
@ -119,7 +119,7 @@
label-connected = %essid%
format-disconnected = <label-disconnected>
label-disconnected = %ifname% disconnected
label-disconnected = disconnected
[module/eth]
@ -134,7 +134,7 @@
format-connected-prefix-background = ${colors.network_module_bg}
format-connected-background = ${colors.foreground}
format-connected-foreground = ${colors.background}
label-connected = %ifname%
label-connected = OK
label-connected-padding = 1
format-disconnected = <label-disconnected>

View File

@ -7,6 +7,5 @@ killall -q polybar
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
# Launch bar1 and bar2
echo "---" | tee -a /tmp/polybar1.log /tmp/polybar2.log
echo "---" | tee -a /tmp/polybar1.log
polybar "fds-bar" >>/tmp/polybar1.log 2>&1 &
polybar "fds-taskbar" >>/tmp/polybar2log 2>&1 &

View File

@ -1,11 +1,11 @@
* {
background: #221e21;
background-dark: #191619;
background-light: #4a4649;
background: #171717;
background-dark: #000000;
background-light: #2e2e2e;
foreground: #e0e1dd;
scrollbar-handle: #656d77;
scrollbar-handle: #5c5c5c;
}
@import "fds-sidebar-common"

View File

@ -34,7 +34,7 @@ super + F12
# Screenshot and screencast launcher.
Print
$HOME/bin/rofi-screen
$HOME/bin/rofi-screen --prompt || $HOME/bin/rofi-screen
# Screenshot with OCR capability
super + shift + w
@ -92,17 +92,11 @@ super + c
bspc node -t '~tiled'
# Desktop and node movements.
super + Tab
bspc desktop next --focus
super + {_, shift + } Tab
bspc desktop {next, prev} --focus
super + shift + Tab
bspc desktop prev --focus
super + grave
bspc desktop last --focus
super + shift + grave
bspc node --to-desktop last
super + {_, shift + } + grave
bspc {desktop last --focus, node --to-desktop last}
super + {Up,Down,Left,Right}
bspc node {north,south,west,east} --focus