wmii configuration script for Pidgin notification - pidgin

I am new to wmii. Could anybody kind enough to share his configuration script with a nice status bar that could display notifications from Pidgin?

OK, I got the notification work for Pidgin.
First, 'command-notification' plugin from Pidgin site, download
Then configure the plugin execute a shell script, like this:
#!/bin/bash
owins=$(wmiir ls /client | grep -v -e 'sel')
for owin in $owins; do
wincount=$(wmiir read /client/$owin/props | grep -c -e "Pidgin:Pidgin")
if [ $wincount != 0 ]; then
wmiir xwrite /client/$owin/ctl Urgent off
wmiir xwrite /client/$owin/ctl Urgent on
wmiir xwrite /event Notice "You have new message!"
fi
done

Related

How to listen for, and act upon, a Mac notification using Automator?

Is it possible to listen for a specific notification on Mac and act upon it using Automator?
I regularly use an app that runs a background job then sends a notification when it's finished. The app stays open after the job is finished so I'd like to use Automator to quit the app when the notification is received.
If it's not possible in Automator is there another way I could do this?
More context: the app is actually launched by a Folder Action created using Automator. It detects when a specific SD card is inserted and runs a backup app on that SD card. So maybe there's something I can add to that Folder Action workflow that can detect the notification?
While it's certainly possible to query the sqlite database containing notifications in macOS, it seems to me like an unnecessarily complicated route, and I would first try the following...
In your workflow, add a 'Run Shell Script' action at the end, containing something like this:
while [ $(ps -e | grep "[N]ameOfBackgroundProcess" | wc -l) -gt 0 ]; do
sleep 3
done
killall "NameOfAppToQuit" 1&>2 /dev/null
The while loop checks whether the background job is still running.
ps -e lists all running processes.
grep "[N]ameOf..." gets all lines containing the name. Brackets around the first letter excludes the grep process itself from the output.
wc -l counts the lines.
-gt 0 checks if the number is greater than zero.
When the loop is done, that means the process has exited so we quit the app with killall.
As for the notification route...
I haven't figured everything out, but this might give you a head start:
#!/usr/bin/env bash
# Get the directory of the Notification Center database (works for me in Big Sur):
db_dir=$(lsof -p $(ps aux | grep -m1 usernoted | awk '{ print $2 }')| awk '{ print $NF }' | grep 'db2/db$' | xargs dirname)
# Get the app_id:
app_id=$(sqlite3 "$db_dir"/db 'SELECT app_id FROM app WHERE identifier="com.example.identifier";')
# Get relevant records:
sqlite3 "$db_dir"/db "SELECT * FROM record WHERE app_id='$app_id';"
# And this is where I leave you.
To explore the database in a GUI, try https://sqlitebrowser.org/

I am looking for help trying to create a .sh file to run steam games through wines windows player

I have a computer running Ubuntu with retropie (emulationstation) which i can create .sh files to run linux based steam games through as they can be directly installed onto the computer. I have installed wine in order to play the windows based games and while I can run the files by going into windows steam and clicking play, I am looking for a way to create a .sh file that will allow me to play them through retropie. I can post some of the stuff ive tried i just am struggling with the formatting.
Let me know if i need to post anything else or fix something!
EDIT: Heres some of the code ive tried, the first i thinks should run the executable through wine but i cant get anything to output, the second is some code i found online which watches for the game to close as well so it can exit clean.
#!/bin/bash
wine ~/PlayOnLinux\'s\ virtual\ drives/Steam/drive_c/Program\
Files/Steam/steamapps/common/MortalKombat_KompleteEdition/DiscContentPC/MKKE.exe
#! /bin/bash
appid=$1
procname=$2
PREFIX=/home/rig-cade/PlayOnLinux\'s\ virtual\ drives
STEAM="/home/rig-cade/.wine-steam/drive_c/Program Files/Steam/Steam.exe"
export WINEDEBUG=-all
export WINEPREFIX=$PREFIX
if [[ ((`pgrep -f steam.exe -c` == 0)) && ((`pgrep -f Steam.exe -c` == 0)) ]]; then
optirun wine "$STEAM" -silent &
sleep 20
fi
echo "Running game"
wine "$STEAM" steam://rungameid/$appid &
sleep 15
echo "Starting checks"
status=`pgrep -f $procname -c`
if (( "$status" > 1 )); then
while (( "$status" > 1 )); do
sleep 5
status=`pgrep -f $procname -c`
done
wine "$STEAM" -shutdown &
fi
echo "Exiting"
I'm not 100% sure and I will test once I get done with work in a couple hours, but AFAIK the Steam URL protocol cannot be used with the command-line and so when you try this Steam is likely throwing a parsing error. If you add -console after -silent it should enable the Console tab and allow you to see an error message if you open the client.
Instead try one of
Only using the browser protocol without the "$STEAM" part so it's not trying to pass it as an argument to the client.
Using the Steam Command-line parameter -applaunch {appid},
where {appid} is replaced with the appid of the game to be run as you were already trying to do.

Nagios custom plugin calling python Openstack Swift client

I want to check with NAGIOS whether my server can connect to Openstack Swift container. I wrote a simple script where I use Swift Python client to get stat of the container
Script looks like that
#!/bin/bash
set -e
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4
if ! which /usr/bin/swift >/dev/null 2>&1
then
echo "Swift command not found"
exit $STATE_UNKNOWN
fi
my_swift="/usr/bin/swift -V 2.0 -A http://my-swift-domain.com:5000/v2.0/ --insecure --os-username my-user-name --os-password my-password --os-tenant-name tenant-name stat container"
output=`$my_swift | grep Objects | sed 's/Objects:\s*\([0-9]*\).*/\1/'`
if [ "$output" -eq "$output" ] 2>/dev/null
then
echo "successfully connected to swift. Number of objects in container $output";
exit $STATE_OK
else
echo "Number of container objects is not correct";
exit $STATE_CRITICAL
fi
Script has right permissions and NAGIOS is able to run it properly. The script itself called from bash works and returns something like:
successfully connected to swift. Number of objects in container 4973123
But it doesn't when I run it via nrpe. I checked it by running /usr/lib64/nagios/plugins/check_nrpe -H 127.0.0.1 -c check_swift
I just get Number of container objects is not correct
After debugging I'm pretty sure that the command
output=`$my_swift | grep Objects | sed 's/Objects:\s*\([0-9]*\).*/\1/'`
is not even called.
I tried to put swift --version there just to see if it will give me some output and it does. So, it let me think that there is something wrong with parameters but I really don't know what, because the command itself called in a shell works perfectly fine.
Any help appreciated :)
Try to change de first line for this:
#!/usr/bin/env bash
Turns out that it was SELinux (on CentOS) blocking the execution of the command because of the wrong context of the file. I copied the file from home directory to Nagios' plugins directory.
restorecon check_swift_container -v helped

notify-send doesn't work in crontab (doesn't send a notification)

I want to make a little script which send me a notification when an update is available for pacman. I did that :
#!/bin/sh
while /usr/bin/inotifywait -e create /var/lib/pacman; do
/usr/bin/notify-send "pacmauto" "Updating...";
updateDone=0
while /usr/bin/inotifywait -e delete /var/lib/pacman -t 30; do
updateDone=1;
done
if [ $updateDone -eq 1 ]; then
/usr/bin/notify-send "pacmauto" "Update done, you can install it with pacman -Su";
fi
done
But the fact is when i use it with my user prompt, it works. But when i want to put it in a crontab, it doesn't send me a notification when it's done. Someone can help me ?
So finally, I follow this topic (http://ubuntuforums.org/showthread.php?t=1533494) and it works now. Thanks you Philibobby !

I am trying to create a shell script that will notify me (not email) if certain users log on to a linux machine

Basically I have a list of user names in a text file that I need to watch. All i need is a simple script to notify me if they log on to the system, but not email me.
This is a brute force solution, using SSH to connect to the server if you specify a user#host combo, or it checks to local machine. It assumes passwordless public-key access and it uses the last command to poll the last logged on user every 30s.
The command notify-send is used for the pop-up which assumes a desktop Linux machine.
#!/bin/sh
host=$1
while true; do
if [ "$host" ]; then
last_user=`ssh $host last`
else
last_user=`last`
fi
last_user=`echo $last_user | head -n1 | awk '{ print $1,$2,$3 }'`
if [ "$last_user" != "$previous_user" ]; then
notify-send $last_user
previous_user=$last_user
fi
sleep 30
done
There is a package called notify-send which would do this. You would have to script logins into notify-send, which in turn would put a notification bubble on screen.

Resources