Ham, minimalist, komut satırı yolu:
sleep 1500; gnome-screensaver-command -l; sleep 300; killall gnome-screensaver
Bu aynı zamanda bir masaüstü kısayoluna ya da .bashrc
Neden 1500 ve 300? çünkü bu saniye, 1500 saniye / dakikada 60 saniye = 25 dakika.
Aşağıda değişken seans ve mola süresi ayarının yanı sıra mola sinyalini verme yöntemlerini belirleyen bir zamanlayıcı için bir script verilmiştir.
Linux'taki herhangi bir betiğin bir dosya olarak kaydedilmesi ve çalıştırılabilir izinlerin ayarlanmış olması gerektiğini unutmayın chmod +x /path/to/script.sh
. Bu yapıldıktan sonra, betiği klavye birleşimine nasıl bağlayabilirim? Bölümünde gösterilen kısayola bağlayabilirsiniz. veya Masaüstümde rampaları nasıl oluşturabilirim? bölümünde gösterildiği gibi bir masaüstü kısayolu oluşturun.
Komut dosyasını başlattığınızda şöyle bir menü görmelisiniz:
#!/bin/bash
# Author: Serg Kolo
# Date : Nov 17th, 2015
# Purpose: pomodoro timer script,
# with bunch of options
# Written for: https://askubuntu.com/q/696620/295286
#####################################################
# screenSaver function
# this one uses gnome-screensaver-command for locking
# and killall for unlocking the screen;
# $1 is provided from chooseBreakMethod function
#####################################################
function screenSaver
{
gnome-screensaver-command -l; sleep $1 ; killall gnome-screensaver
}
##############################################
# dialogBreak function
# this serves as "screensaver". The screen is never
# actually locked but rather we open terminal window
# with a simple command line dialog
# in full sccrean mode
# $1 provided in chooseBreakMethod function
##################################################
function dialogBreak
{
gnome-terminal --full-screen -e "bash -c 'sleep $1 | dialog --progressbox \"TAKE A BREAK\" 100 100 ' "
}
#################################################################
# dimScreen function
# dims the screen using xrandr; the --brightness
# can be configured
# for full or partial dimming using decimal values
# from 1 to 0
# $1 is provided from chooseBreakMethod function
################################################################
function dimScreen
{
xrandr | awk '$2 == "connected" {print $1}' | xargs -I % xrandr --output % --brightness 0.5
notify-send 'Take a Break'
sleep $1
xrandr | awk '$2 == "connected" {print $1}' | xargs -I % xrandr --output % --brightness 1
}
##############################
# getSettings function
# This is where the user enters
# the settings they want
# All the values must be integers
#############################
function getSettings
{
FORM=$(zenity --forms \ --title="Sergiy's Tomato Script" --text="Choose this session options" \
--add-entry="Number of Sessions (how many loops)" \
--add-entry="Session time (minutes)" \
--add-entry="Break time (minutes)" \
--add-entry="Dim,dialog,or screensaver? (1,2,3)" \
--separator=" " )
[ $? -eq 0 ] || exit 1
echo $FORM
}
################################
# chooseBreakMethod function
# A helper function that calls appropriate
# break method, based on the value we got
# from getSettings function
# Because dialogBreak calls gnome-terminal
# this function exits, so it doesn't wait
# Therefore we need to add additional sleep
# command
###############################
function chooseBreakMethod
{
# $1 is method passed from ${SETS[3]}
# $2 is break time passed from ${SETS[2]}
case $1 in
1) dimScreen $2 ;;
2) dialogBreak $2 ; sleep $2 ;;
3) screenSaver $2 ;;
esac
}
function minutesToSeconds
{
echo $(($1*60))
}
#################
# MAIN
#################
# get user settings and store them into array
# Item 0 : num sessions
# Item 1 : session duration
# Item 2 : break duration
# Item 3 : break method - lockscreen, dialog, or just
# turn off the screen
# SETS == settings
SETS=( $(getSettings) )
COUNTER=${SETS[0]}
#######################################
# This is where most of the job is done
# we loop according to number of session
# specified in the getSettings function
#########################################
notify-send 'Session started'
while [ $COUNTER -ne 0 ]; do
sleep $( minutesToSeconds ${SETS[1]} ) # session timer
chooseBreakMethod ${SETS[3]} $( minutesToSeconds ${SETS[2]} )
COUNTER=$(($COUNTER-1))
done
notify-send "tomatoScript is done"
####### END OF SCRIT ###########