<commit_before>#!/bin/bash

# Requirements: xssstate, i3lock

if [ -f "/tmp/xscreen-lock" ]; then
	exit 0
fi
touch /tmp/xscreen-lock

# Use xset s $time to control the timeout when this will run.
xset s 300

cmd="i3lock"
# Check if the 1st argument is file
if [ $# -eq 1 ] && [ -f $1 ]; then
	mime=$(file --mime-type $1 | cut -d \  -f2)
	# Check if it's a PNG file
	if [ $(echo $mime|grep -i png|wc -l) -eq 1 ]; then
		cmd="i3lock -ti $1"
	fi
fi

while true
do
	if [ $(xssstate -s) != "disabled" ];
	then
		tosleep=$(($(xssstate -t) / 1000))
		if [ $tosleep -le 0 ];
		then
			$cmd
		else
			sleep $tosleep
		fi
	else
		sleep 10
	fi
done
<commit_msg>Disable screensaver when some blocker apps are present<commit_after>#!/bin/bash

# Set timeout length
timeout="300"

# Requirements: xssstate, i3lock

if [ -f "/tmp/xscreen-lock" ]; then
	exit 0
fi
touch /tmp/xscreen-lock

# Use xset s $time to control the timeout when this will run.
xset s $timeout

cmd="i3lock"
# Check if the 1st argument is file
if [ $# -eq 1 ] && [ -f $1 ]; then
	mime=$(file --mime-type $1 | cut -d \  -f2)
	# Check if it's a PNG file
	if [ $(echo $mime|grep -i png|wc -l) -eq 1 ]; then
		cmd="i3lock -ti $1"
	fi
fi

while true
do
	# If some blocker programs are found then disable screensaver
	blockers=$(ps aux|grep -E 'vlc'|grep -v grep|wc -l)
	if [ $blockers -gt 0 ]; then
		xset s off
	else
		xset s $timeout
	fi

	if [ $(xssstate -s) != "disabled" ];
	then
		tosleep=$(($(xssstate -t) / 1000))
		if [ $tosleep -le 0 ];
		then
			$cmd
		else
			sleep $tosleep
		fi
	else
		sleep 10
	fi
done

{'fraction_non_alphanumeric': 0.14394904458598726, 'fraction_numerical': 0.027388535031847135, 'mean_word_length': 2.7946859903381642, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '896051', 'n_tokens_mistral': 708, 'n_tokens_neox': 639, 'n_words': 228}