mirror of
https://github.com/zedsalim/debian-z.git
synced 2025-12-14 15:19:29 +00:00
Add youtube blocker script
This commit is contained in:
parent
a9b7b183c4
commit
24dc2063b8
4 changed files with 36 additions and 1 deletions
30
config/scripts/yt_blocker.sh
Executable file
30
config/scripts/yt_blocker.sh
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
# YouTube domain to block
|
||||
youtube_domain="www.youtube.com"
|
||||
|
||||
# IP address to redirect to (localhost)
|
||||
redirect_ip="127.0.0.1"
|
||||
|
||||
# Prompt for the duration using dmenu
|
||||
duration=$(rofi -dmenu -p "Enter block duration (minutes): ")
|
||||
|
||||
# Backup the original hosts file
|
||||
cp /etc/hosts /etc/hosts.backup
|
||||
|
||||
# Add an entry to redirect YouTube to the specified IP address
|
||||
bash -c "echo $redirect_ip $youtube_domain >> /etc/hosts"
|
||||
|
||||
# Wait for the specified duration
|
||||
sleep "${duration}m"
|
||||
|
||||
# Remove the entry from the hosts file to unblock YouTube
|
||||
sed -i "/$youtube_domain/d" /etc/hosts
|
||||
|
||||
# Remove the backup file
|
||||
sudo rm /etc/hosts.backup
|
||||
|
||||
# Notification
|
||||
notify-send 'Y-Blocker' 'YouTube unblocked'
|
||||
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue