mirror of
https://github.com/tanrax/bash-folders.git
synced 2024-12-22 18:25:35 +01:00
Remove native notification
This commit is contained in:
parent
81c4d6c449
commit
6e3f3e4272
@ -16,13 +16,12 @@ Folder that watches when new videos are added and optimizes them.
|
|||||||
|
|
||||||
### Requirements
|
### Requirements
|
||||||
|
|
||||||
- `inotify-tools`
|
|
||||||
- `ffmpeg`
|
- `ffmpeg`
|
||||||
|
|
||||||
Example in Debian.
|
Example in Debian.
|
||||||
|
|
||||||
``` sh
|
``` sh
|
||||||
sudo apt install inotify-tools ffmpeg
|
sudo apt install ffmpeg
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install
|
### Install
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# Description: Script that watches when new videos are added to a folder and optimizes them.
|
# Description: Script that watches when new videos are added to a folder and optimizes them.
|
||||||
# --
|
# --
|
||||||
# Requirements: Install inotify-tools and ffmpeg
|
# Requirements: Install inotify-tools and ffmpeg
|
||||||
# Example Debian: $sudo apt install inotify-tools ffmpeg
|
# Example Debian: $sudo apt install ffmpeg
|
||||||
# --
|
# --
|
||||||
# Cron: @reboot bash-folders-video-optimizer.sh >/dev/null 2>&1 &
|
# Cron: @reboot bash-folders-video-optimizer.sh >/dev/null 2>&1 &
|
||||||
# --
|
# --
|
||||||
@ -12,10 +12,6 @@
|
|||||||
# START
|
# START
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# EXPORTS
|
|
||||||
# Fix: notify-send command doesn't launch the notification through systemd service
|
|
||||||
export DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-unix:path=/run/user/${UID}/bus}"
|
|
||||||
|
|
||||||
# VARIABLES
|
# VARIABLES
|
||||||
PROGNAME=$(basename "$0")
|
PROGNAME=$(basename "$0")
|
||||||
FOLDER_ORIGIN="$2"
|
FOLDER_ORIGIN="$2"
|
||||||
@ -40,17 +36,6 @@ EOF
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
send-notification() {
|
|
||||||
if command -v notify-send >/dev/null 2>&1; then
|
|
||||||
# Send a native notification
|
|
||||||
notify-send "$1"
|
|
||||||
else
|
|
||||||
# If the above command is not available, print by console
|
|
||||||
echo "$1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
# Monitors the selected folder
|
# Monitors the selected folder
|
||||||
inotifywait -m -e create,moved_to --format '%f' "$FOLDER_ORIGIN" |
|
inotifywait -m -e create,moved_to --format '%f' "$FOLDER_ORIGIN" |
|
||||||
@ -63,16 +48,12 @@ start() {
|
|||||||
# Check if the file name starts with "optimized"
|
# Check if the file name starts with "optimized"
|
||||||
if [[ "$filename" != optimized* ]]; then
|
if [[ "$filename" != optimized* ]]; then
|
||||||
filename_output="optimized_${filename%.*}.mp4"
|
filename_output="optimized_${filename%.*}.mp4"
|
||||||
# Notifies that the conversion is to be started
|
|
||||||
send-notification "Optimizing $filename_output ..."
|
|
||||||
# Displays a flat file of information
|
# Displays a flat file of information
|
||||||
touch "$FOLDER_ORIGIN/$MESSAGE_WAITING"
|
touch "$FOLDER_ORIGIN/$MESSAGE_WAITING"
|
||||||
# Convert the file to MP4 format using ffmpeg in /tmp/
|
# Convert the file to MP4 format using ffmpeg in /tmp/
|
||||||
ffmpeg -i "$FOLDER_ORIGIN/$filename" -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -nostdin -shortest "/tmp/$filename_output"
|
ffmpeg -i "$FOLDER_ORIGIN/$filename" -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -nostdin -shortest "/tmp/$filename_output"
|
||||||
# When finished move the optimized file
|
# When finished move the optimized file
|
||||||
mv "/tmp/$filename_output" "$FOLDER_ORIGIN/$filename_output"
|
mv "/tmp/$filename_output" "$FOLDER_ORIGIN/$filename_output"
|
||||||
# Notifies that it has been terminated
|
|
||||||
send-notification "Completed! Output: $filename_output"
|
|
||||||
# Remove a flat file of information
|
# Remove a flat file of information
|
||||||
rm "$FOLDER_ORIGIN/$MESSAGE_WAITING"
|
rm "$FOLDER_ORIGIN/$MESSAGE_WAITING"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user