💾 Archived View for gemini.ctrl-c.club › ~hexagram23 › gemlog › entries › 20230721_irischk.gmi captured on 2023-07-22 at 16:13:09. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Automatically checking for new iris messages on ^C - 2023-07-21

Introducing irischk.sh and irishchk-auto.sh

One of the unique features of ^C is iris, the message base written by calamitous. It's relatively low-traffic, and while I could keep it open in interactive mode and issue the 'f' or 'freshen' command occasionally to check for new messages, I don't want to.

My solution is 2 bash scripts. irischk.sh and irischk-auto.sh

irischk.sh

#!/bin/bash
# by Hex hexagram23@ctrl-c.club
# This work is licensed under the Creative Commons Attribution 4.0 International License. 
# To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to:
# Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

output=$(iris -s)  # Runs 'iris -s' command and stores output.

if echo "$output" | grep -q ", 0 unread"
then
	echo "iris has no unread messages."
else
	echo "iris has unread messages."
fi

irischk-auto.sh

#!/bin/bash
# by Hex hexagram23@ctrl-c.club
# This work is licensed under the Creative Commons Attribution 4.0 International License. 
# To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to:
# Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

file_path=~/.irischk-auto

if [ -f "$file_path" ]
then
	#semaphore file exists
	current_time=$(date +%s)
	file_time=$(stat -c %Y "$file_path")

	if (( current_time - file_time >= 3600 ))
	#semaphore file is more than an hour old
	then
		irischk
		touch "$file_path"
	fi
else
	#semaphore file doesn't exist
	irischk
	touch "$file_path"
fi

How to use them and caveats

Create each file in your personal bin directory and make sure they're executable. Run irischk-auto and it should perform its first check. In order to have it check every time you're presented with a bash prompt, add it to your PROMPT_COMMAND setting.

Because invoking iris is a little slow and it's unnecessary to really check that often, I use the ~/.irischk-auto semaphore file to make sure it's only checked every 60 minutes. Adjust the 3600 seconds in irischk-auto.sh to your whim.

This software is only lightly tested but it should work. It's possible but unlikely that calamitous will change the output of the 'iris -s' function, but that should be easy to address. Please report any issues to me via hexagram23@ctrl-c.club and I'll try to address them.

Why two scripts? Because I want the ability to check iris manually.

Hex's Gemlog

Copyright (C) 2023 by Hex

This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.