{"id":20272134,"url":"https://github.com/tanrax/bash-folders","last_synced_at":"2025-04-11T04:40:55.143Z","repository":{"id":153452816,"uuid":"617109442","full_name":"tanrax/bash-folders","owner":"tanrax","description":"Small collection of Bash scripts to launch functionalities in folders when new files appear, such as optimizing videos, converting images or battery management.","archived":false,"fork":false,"pushed_at":"2023-11-04T14:03:56.000Z","size":131,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-25T02:43:48.057Z","etag":null,"topics":["bash","battery","compression","folder","image","video","webp"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tanrax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-03-21T18:06:20.000Z","updated_at":"2024-10-03T05:17:03.000Z","dependencies_parsed_at":"2023-05-31T18:45:40.445Z","dependency_job_id":"ac3001a4-f108-4c8e-8d5e-8ddb222293dd","html_url":"https://github.com/tanrax/bash-folders","commit_stats":{"total_commits":63,"total_committers":2,"mean_commits":31.5,"dds":0.4444444444444444,"last_synced_commit":"95b052346e61dc40477ec00a58f4931a2d664534"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanrax%2Fbash-folders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanrax%2Fbash-folders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanrax%2Fbash-folders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanrax%2Fbash-folders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tanrax","download_url":"https://codeload.github.com/tanrax/bash-folders/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345275,"owners_count":21088242,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","battery","compression","folder","image","video","webp"],"created_at":"2024-11-14T12:41:58.803Z","updated_at":"2025-04-11T04:40:55.121Z","avatar_url":"https://github.com/tanrax.png","language":"Shell","readme":"# Bash folders\n\n![Bash folder brand](assets/social.webp)\n\nSmall collection of Bash scripts to launch functionalities in folders when new files appear, such as optimizing videos, converting images or battery management.\n\n- [Video optimizer](#video-optimizer): Folder that watches when new videos are added and optimizes them.\n- [Battery hook](#battery-hook): Folder with custom scripts to be launched in different battery states.\n- [Image to AVIF](#image-to-avif): Folder that watches when new image (PNG, JPEG or WebP) are added and transform to AVIF format.\n- [Image to WebP](#image-to-webp): Folder that watches when new image (PNG or JPEG) are added and transform to WebP format.\n\n---\n\n## Video optimizer\n\nFolder that watches when new videos are added and optimizes them.\n\n### Requirements\n\n- `ffmpeg`\n\nExample in Debian.\n\n``` sh\nsudo apt install ffmpeg inotify-tools\n```\n\n### Install\n\n\n``` sh\ncurl -o bash-folders-video-optimizer https://raw.githubusercontent.com/tanrax/bash-folders/main/bash-folders-video-optimizer.sh \u0026\u0026 chmod +x bash-folders-video-optimizer \u0026\u0026 sudo rm -f /usr/local/bin/bash-folders-video-optimizer \u0026\u0026 sudo mv bash-folders-video-optimizer /usr/local/bin \u0026\u0026 echo \"🎉 Successfully installed! 🎉\"\n```\n\nTest\n\n``` sh\nbash-folders-video-optimizer --help\n```\n\n### Run\n\n``` sh\nbash-folders-video-optimizer --folder [folder to watch]\n```\n\nExample.\n\n``` sh\nmkdir optimizer\nbash-folders-video-optimizer --folder optimizer\n```\n\nAnd leave a video that you want to optimize in the folder `optimizer`.\n\n### Start at operating system startup\n\n#### Option 1: Service\n\nCreate a file in `/etc/systemd/system/bash-folders-video-optimizer.service` with the following content.\n\n\n```ini\n[Unit]\nDescription=Folder that watches when new videos are added and optimizes them.\n\n[Service]\nRestart=always\nRestartSec=5\nUser=[user]\nExecStart=bash-folders-video-optimizer --folder [folder to watch]\n\n[Install]\nWantedBy=multi-user.target\n```\n\nEdit it to your needs.\n\nRecharge services.\n\n``` sh\nsudo systemctl daemon-reload\n```\n\nAnd activate it.\n\n``` sh\nsudo systemctl enable bash-folders-video-optimizer\nsudo systemctl start bash-folders-video-optimizer\n```\n\n#### Option 2: Cron\n\nOpen.\n\n``` sh\ncrontab -e\n```\n\nAdd to document.\n\n``` sh\n@reboot bash-folders-video-optimizer --folder [folder to watch] \u003e/dev/null 2\u003e\u00261 \u0026\n```\n\n---\n\n## Battery hook\n\nFolder with custom scripts to be launched in different battery states.\n\nThe filename of the scripts, or your custom scripts,  must be:\n\n- `discharging`: When the battery is in use.\n- `charging`: When the battery is charging.\n- `low`: When it reaches the low percentage. Default 20.\n- `high`: When it reaches the high percentage. Default 80.\n- `full`: When the battery is full.\n\nThey must have **execution permissions**. If any of them do not exist, they will be ignored.\n\n### Install\n\n\n``` sh\ncurl -o bash-folders-battery-hook https://raw.githubusercontent.com/tanrax/bash-folders/main/bash-folders-battery-hook.sh \u0026\u0026 chmod +x bash-folders-battery-hook \u0026\u0026 sudo rm -f /usr/local/bin/bash-folders-battery-hook \u0026\u0026 sudo mv bash-folders-battery-hook /usr/local/bin \u0026\u0026 echo \"🎉 Successfully installed! 🎉\"\n```\n\nTest\n\n``` sh\nbash-folders-battery-hook --help\n```\n\n### Run\n\n``` sh\nbash-folders-battery-hook --folder [folder path]\n```\n\nExample.\n\n``` sh\nmkdir battery-scripts\n\nbash-folders-battery-hook --folder battery-scripts\n```\n\nInside the folder all the empty scripts will be created, which you will have to edit to include the instructions in Bash.\n\n### Start at operating system startup\n\n#### Option 1: Service\n\nCreate a file in `/etc/systemd/system/bash-folders-battery-hook.service` with the following content.\n\n\n```ini\n[Unit]\nDescription=Folder with custom scripts to be launched in different battery states.\n\n[Service]\nRestart=always\nRestartSec=5\nUser=[user]\nExecStart=bash-folders-battery-hook --folder [folder path]\n\n[Install]\nWantedBy=multi-user.target\n```\n\nEdit it to your needs.\n\nNow you will need the script to run every so often to check the battery status. The best solution is to create a `timer`.\n\nCreate a file in `/etc/systemd/system/bash-folders-battery-hook.timer` with the following content.\n\n```ini\n[Unit]\nDescription=Folder with custom scripts to be launched in different battery states every minute.\n\n[Timer]\nOnCalendar=*-*-* *:*:00\nPersistent=true\n\n[Install]\nWantedBy=timers.target\n```\n\nRecharge services.\n\n``` sh\nsudo systemctl daemon-reload\n```\n\nAnd activate it.\n\n``` sh\nsudo systemctl enable bash-folders-battery-hook.timer\nsudo systemctl start bash-folders-battery-hook.timer\n```\n\n#### Option 2: Cron\n\nOpen.\n\n``` sh\ncrontab -e\n```\n\nAdd to document.\nCollaborations \u0026 Pull Requests\n``` sh\n* * * * * bash-folders-battery-hook --folder [folder path]\n```\n\n---\n\n## Image to AVIF\n\nFolder that watches when new image (PNG, JPEG or WebP) are added and transform to AVIF format.\n\n### Requirements\n\n- `avifenc`\n\nExample in Debian.\n\n``` sh\nsudo apt install libavif-bin\n```\n\n### Install\n\n\n``` sh\ncurl -o bash-folders-image-to-avif https://raw.githubusercontent.com/tanrax/bash-folders/main/bash-folders-image-to-avif.sh \u0026\u0026 chmod +x bash-folders-image-to-avif \u0026\u0026 sudo rm -f /usr/local/bin/bash-folders-image-to-avif \u0026\u0026 sudo mv bash-folders-image-to-avif /usr/local/bin \u0026\u0026 echo \"🎉 Successfully installed! 🎉\"\n```\n\nTest\n\n``` sh\nbash-folders-image-to-avif --help\n```\n\n### Run\n\n``` sh\nbash-folders-image-to-avif --folder [folder to watch]\n```\n\nExample.\n\n``` sh\nmkdir image-to-avif-converter\nbash-folders-image-to-avif --folder image-to-avif-converter\n```\n\nAnd leave a image that you want to optimize in the folder `image-to-avif-converter`.\n\n---\n\n### Start at operating system startup\n\n#### Option 1: Service\n\nCreate a file in `/etc/systemd/system/bash-folders-image-to-avif.service` with the following content.\n\n\n```ini\n[Unit]\nDescription=Folder that watches when new image (PNG, JPEG or WebP) are added and transform to AVIF format.\n\n[Service]\nRestart=always\nRestartSec=5\nUser=[user]\nExecStart=bash-folders-image-to-avif --folder [folder to watch]\n\n[Install]\nWantedBy=multi-user.target\n```\n\nEdit it to your needs.\n\nRecharge services.\n\n``` sh\nsudo systemctl daemon-reload\n```\n\nAnd activate it.\n\n``` sh\nsudo systemctl enable bash-folders-image-to-avif\nsudo systemctl start bash-folders-image-to-avif\n```\n\n#### Option 2: Cron\n\nOpen.\n\n``` sh\ncrontab -e\n```\n\nAdd to document.\n\n``` sh\n@reboot bash-folders-image-to-avif --folder [folder to watch] \u003e/dev/null 2\u003e\u00261 \u0026\n```\n\n---\n\n## Image to WebP\n\nFolder that watches when new image (PNG or JPEG) are added and transform to WebP format.\n\n### Requirements\n\n- `webp`\n\nExample in Debian.\n\n``` sh\nsudo apt install webp\n```\n\n### Install\n\n\n``` sh\ncurl -o bash-folders-image-to-webp https://raw.githubusercontent.com/tanrax/bash-folders/main/bash-folders-image-to-webp.sh \u0026\u0026 chmod +x bash-folders-image-to-webp \u0026\u0026 sudo rm -f /usr/local/bin/bash-folders-image-to-webp \u0026\u0026 sudo mv bash-folders-image-to-webp /usr/local/bin \u0026\u0026 echo \"🎉 Successfully installed! 🎉\"\n```\n\nTest\n\n``` sh\nbash-folders-image-to-webp --help\n```\n\n### Run\n\n``` sh\nbash-folders-image-to-webp --folder [folder to watch]\n```\n\nExample.\n\n``` sh\nmkdir image-to-webp-converter\nbash-folders-image-to-webp --folder image-to-webp-converter\n```\n\nAnd leave a image that you want to optimize in the folder `image-to-webp-converter`.\n\n### Start at operating system startup\n\n#### Option 1: Service\n\nCreate a file in `/etc/systemd/system/bash-folders-image-to-webp.service` with the following content.\n\n\n```ini\n[Unit]\nDescription=Folder that watches when new image (PNG or JPEG) are added and transform to WebP format.\n\n[Service]\nRestart=always\nRestartSec=5\nUser=[user]\nExecStart=bash-folders-image-to-webp --folder [folder to watch]\n\n[Install]\nWantedBy=multi-user.target\n```\n\nEdit it to your needs.\n\nRecharge services.\n\n``` sh\nsudo systemctl daemon-reload\n```\n\nAnd activate it.\n\n``` sh\nsudo systemctl enable bash-folders-image-to-webp\nsudo systemctl start bash-folders-image-to-webp\n```\n\n#### Option 2: Cron\n\nOpen.\n\n``` sh\ncrontab -e\n```\n\nAdd to document.\n\n``` sh\n@reboot bash-folders-image-to-webp --folder [folder to watch] \u003e/dev/null 2\u003e\u00261 \u0026\n```\n\n---\n\n## Collaborations \u0026 Pull Requests\n\nYou must provide the documentation, as well as the scripts present, test that it works well and the script must pass a `shellcheck` (below you will find an example of execution).\n\n```sh\nshellcheck [script]\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanrax%2Fbash-folders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftanrax%2Fbash-folders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanrax%2Fbash-folders/lists"}