diff options
author | Mario Izquierdo (mariodebian) <mariodebian@gmail.com> | 2012-06-22 12:42:53 +0100 |
---|---|---|
committer | Mario Izquierdo (mariodebian) <mariodebian@gmail.com> | 2012-06-22 12:42:53 +0100 |
commit | 85e11fb132b2b81b50a45647b070e8f6fd648d65 (patch) | |
tree | 1238a0e269d68604457ef6435e1c7ec18ffe7e20 /session-cmd |
tcos (0.89.90) unstable; urgency=low
* debian/initramfs-tools-tcos.postrm:
- piuparts, don't call delgroup if can't
* Add overlayfs as aufs alternative
* hooks-addons/clean_initramfs: multiarch with libpci3
* Simplify grep commands
* Install conf/tcos.conf instead of conf/tcos.conf.etc
* Use a global LIB_MULTIARCH var
* tcos-standalone French translation, thanks to Julien Patriarca, (closes: #672135)
# imported from the archive
Diffstat (limited to 'session-cmd')
-rw-r--r-- | session-cmd/Makefile | 17 | ||||
-rw-r--r-- | session-cmd/session-cmd-common.sh | 52 | ||||
-rwxr-xr-x | session-cmd/session-cmd-exec | 117 | ||||
-rwxr-xr-x | session-cmd/session-cmd-script | 51 | ||||
-rwxr-xr-x | session-cmd/session-cmd-send | 32 | ||||
-rw-r--r-- | session-cmd/session-cmd.desktop | 9 |
6 files changed, 278 insertions, 0 deletions
diff --git a/session-cmd/Makefile b/session-cmd/Makefile new file mode 100644 index 0000000..c02c34d --- /dev/null +++ b/session-cmd/Makefile @@ -0,0 +1,17 @@ +all: + @echo " session-cmd: make all empty" + +include ../common.mk + +clean: + $(QUIET_CL)rm -f *~ + +install: + install -m 755 session-cmd-send $(DESTDIR)/${TCOS_BINS}/ + install -m 755 session-cmd-exec $(DESTDIR)/${TCOS_BINS}/ + install -m 755 session-cmd-script $(DESTDIR)/${TCOS_BINS}/ + install -m 644 session-cmd-common.sh $(DESTDIR)/${TCOS_BINS}/ + + mkdir -p $(DESTDIR)/etc/xdg/autostart/ + install -m 644 session-cmd.desktop $(DESTDIR)/etc/xdg/autostart/ + diff --git a/session-cmd/session-cmd-common.sh b/session-cmd/session-cmd-common.sh new file mode 100644 index 0000000..41f6069 --- /dev/null +++ b/session-cmd/session-cmd-common.sh @@ -0,0 +1,52 @@ +# ------- +# File: session-cmd-common.sh +# Description: common functions for session-cmd scripts +# Author: Luis Garcia Gisbert <garcia_luigis@gva.es> +# Copyright (C) Luis Garcia Gisbert <garcia_luigis@gva.es> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA +# -------- + +UNIX_SOCKET_DIR="/tmp/session-cmd" + +socket_basename(){ + echo "$(id -un)" +} + +create_socket(){ + local i MAX_TRY UNIX_SOCKET + i=0 + MAX_TRY=99 + while [ $i -lt $MAX_TRY ] ; do + UNIX_SOCKET="${UNIX_SOCKET_DIR}-$(socket_basename)/$(socket_basename)-${i}" + [ -S "${UNIX_SOCKET}.sock" ] || break + if [ -r "${UNIX_SOCKET}.pid" ] ; then + kill -9 "$(cat "${UNIX_SOCKET}.pid")" >/dev/null 2>/dev/null || true + break + fi + i=$(($i + 1)) + done + [ $i -lt $MAX_TRY ] || return 1 + mkdir -p "${UNIX_SOCKET_DIR}-$(socket_basename)" + [ -d "${UNIX_SOCKET_DIR}-$(socket_basename)" ] || return 1 + echo "$UNIX_SOCKET" + return 0 +} + +list_sockets(){ + [ -d "${UNIX_SOCKET_DIR}-$(socket_basename)" ] || return 0 + find "${UNIX_SOCKET_DIR}-$(socket_basename)" -type s -name "$(socket_basename)-*.sock" 2>/dev/null + return 0 +} diff --git a/session-cmd/session-cmd-exec b/session-cmd/session-cmd-exec new file mode 100755 index 0000000..a9a4ef9 --- /dev/null +++ b/session-cmd/session-cmd-exec @@ -0,0 +1,117 @@ +#!/bin/sh +# ------- +# File: session-cmd-exec +# Description: session-cmd backend +# Author: Luis Garcia Gisbert <garcia_luigis@gva.es> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA +# -------- + + +set -e + +[ -r /etc/tcos/tcos.conf ] && . /etc/tcos/tcos.conf + +# title of popup +TITLE="TCOS" + +# icon to show in popup +ICON_FILE="/usr/share/pixmaps/tcos-icon-32x32.png" + +MODE=$1 +shift + +# timeout for popup (in seconds) +LOGOUT_TIMEOUT=20 +[ $# -gt 1 ] && LOGOUT_TIMEOUT=$1 && shift + + +# message to show in popup +LOGOUT_MESSAGE="Session will close in $LOGOUT_TIMEOUT seconds" +POWEROFF_MESSAGE="Pc will shutdown in $LOGOUT_TIMEOUT seconds" +REBOOT_MESSAGE="Pc will reboot in $LOGOUT_TIMEOUT seconds" + +case ${MODE} in + POWEROFF) + POWEROFF_MESSAGE="$*" + ;; + REBOOT) + REBOOT_MESSAGE="$*" + ;; + LOGOUT) + LOGOUT_MESSAGE="$*" + ;; +esac + +if [ -d /etc/tcos/conf.d/ ]; then + for file in /etc/tcos/conf.d/session-cmd*; do + [ -e $file ] && . $file + done +fi + + +MESSAGE_CMD="notify-send -u normal -t $(($LOGOUT_TIMEOUT * 1000)) -i ${ICON_FILE} ${TITLE}" + + +message(){ + $MESSAGE_CMD "$1" 2>/dev/null +} + +socket_basename(){ + echo "$(id -un)" +} + +case ${MODE} in + MESSAGE) + if [ "$*" ] ; then + message "$*" + fi + ;; + POWEROFF) + message "$POWEROFF_MESSAGE" + ;; + REBOOT) + message "$REBOOT_MESSAGE" + ;; + LOGOUT) + message "$LOGOUT_MESSAGE" + sleep $LOGOUT_TIMEOUT + if [ `ps -U $(socket_basename) | grep -c -e "ksmserver" -e "start_kdeinit"` -eq 2 ];then + dcop ksmserver default logout 0 -1 -1 + else + if [ $(gnome-session-save --help | grep -c force-logout) -ge 1 ]; then + gnome-session-save --force-logout + else + gnome-session-save --kill --silent + fi + fi + ;; + NOSCREENSAVER) + if [ `ps -U $(socket_basename) | grep -c -e "ksmserver" -e "start_kdeinit"` -eq 2 ];then + dcop kdesktop KScreensaverIface quit + fi + if [ -f /usr/bin/gnome-screensaver-command ];then + gnome-screensaver-command -d + elif [ -f /usr/bin/xscreensaver-command ];then + xscreensaver-command --deactivate + fi + ;; + OPEN) + if [ "$*" ] ; then + [ -x /usr/bin/gnome-open ] && gnome-open "$*" 2>/dev/null + fi + ;; +esac +exit 0 diff --git a/session-cmd/session-cmd-script b/session-cmd/session-cmd-script new file mode 100755 index 0000000..94b19b3 --- /dev/null +++ b/session-cmd/session-cmd-script @@ -0,0 +1,51 @@ +#!/bin/sh +# ------- +# File: session-cmd-script +# Description: session-cmd session script +# Author: Luis Garcia Gisbert <garcia_luigis@gva.es> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA +# -------- + +######### changed by mariodebian ######## +[ -e /etc/default/tcos-standalone ] && . /etc/default/tcos-standalone + +if [ -f /usr/share/pyshared/tcosmonitor/shared.py ]; then + DISPLAY_HOST=$(python /usr/share/pyshared/tcosmonitor/shared.py "$DISPLAY" 2>/dev/null) +else + DISPLAY_HOST=$(python -c 'import os; import tcosmonitor.shared; print tcosmonitor.shared.parseIPAddress(os.environ["DISPLAY"])') +fi + +if [ -z ${DISPLAY_HOST} ] && [ "${TCOS_STANDALONE_START}" != "1" ]; then + exit 0 +fi +################# end #################### + +LIB_FILE="/usr/lib/tcos/session-cmd-common.sh" +[ -r "$LIB_FILE" ] || exit 1 +. ${LIB_FILE} +EXEC_SCRIPT="/usr/lib/tcos/session-cmd-exec" + +# kill before launching again +killall -w faucet >/dev/null 2>&1 + +sleep 2 + +UNIX_SOCKET="$(create_socket)" || exit 0 +rm -f "${UNIX_SOCKET}.sock" "${UNIX_SOCKET}.pid" +cd /tmp +umask 0177 +faucet "${UNIX_SOCKET}.sock" --unix --pidfile "${UNIX_SOCKET}.pid" --in xargs ${EXEC_SCRIPT} >/dev/null 2>&1 +exit 0 diff --git a/session-cmd/session-cmd-send b/session-cmd/session-cmd-send new file mode 100755 index 0000000..cbec892 --- /dev/null +++ b/session-cmd/session-cmd-send @@ -0,0 +1,32 @@ +#!/bin/sh +# ------- +# File: session-cmd-send +# Description: session-cmd frontend +# Author: Luis Garcia Gisbert <garcia_luigis@gva.es> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA +# -------- + +LIB_FILE="/usr/lib/tcos/session-cmd-common.sh" +[ -r "$LIB_FILE" ] || exit 1 +. ${LIB_FILE} + +DATA="$@" +if [ "$1" ] ; then + for SOCKET in $(list_sockets) ; do + hose localhost "$SOCKET" --unix --out /bin/echo "$DATA" 2>/dev/null || true + done +fi +exit 0 diff --git a/session-cmd/session-cmd.desktop b/session-cmd/session-cmd.desktop new file mode 100644 index 0000000..ae1bafb --- /dev/null +++ b/session-cmd/session-cmd.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Session Cmd +Comment=Session cmd user agent +Exec=/usr/lib/tcos/session-cmd-script +Terminal=false +Type=Application +Categories= +OnlyShowIn=GNOME;XFCE; |