From 61765e0aaae479b94a3fddd01e4e12eae76bb8da Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Fri, 16 Nov 2012 09:53:35 +0000 Subject: Move the remaining scripts to commands --- (limited to 'commands/helpers') diff --git a/commands/helpers/find-free-display.c b/commands/helpers/find-free-display.c new file mode 100644 index 0000000..4a07131 --- /dev/null +++ b/commands/helpers/find-free-display.c @@ -0,0 +1,25 @@ +#include +#include + +int main(int argc, char **argv) +{ + int port; + + for (port = 99; port < 1000; port++) { + char display_name[255]; + + sprintf(display_name, ":%d", port); + Display *dpy = XOpenDisplay(display_name); + + if (!dpy) { + printf(display_name); + return 0; + } else { + XCloseDisplay(dpy); + } + } + + printf("No free display found"); + + return 0; +} diff --git a/commands/helpers/get-screen-dpi b/commands/helpers/get-screen-dpi new file mode 100755 index 0000000..8165920 --- /dev/null +++ b/commands/helpers/get-screen-dpi @@ -0,0 +1,6 @@ +#!/usr/bin/python + +from gi.repository import Gtk + +settings = Gtk.Settings.get_default() +print settings.get_property('gtk-xft-dpi') / 1024 diff --git a/commands/helpers/list-outputs.c b/commands/helpers/list-outputs.c new file mode 100644 index 0000000..183258c --- /dev/null +++ b/commands/helpers/list-outputs.c @@ -0,0 +1,33 @@ +#include +#include + +int main(int argc, char **argv) +{ + Display *dpy = XOpenDisplay(NULL); + XRRScreenResources *rr; + XRROutputInfo *output; + int i; + + XSynchronize(dpy, 1); + + rr = XRRGetScreenResources(dpy, DefaultRootWindow(dpy)); + + if (rr != NULL) { + for (i = 0; i < rr->noutput; i++) { + output = XRRGetOutputInfo(dpy, rr, rr->outputs[i]); + + if (output->connection == RR_Connected) { + printf("%s\n", output->name); + } + + XRRFreeOutputInfo(output); + } + } + + XRRFreeScreenResources(rr); + + XSync(dpy, 1); + XCloseDisplay(dpy); + + return 0; +} diff --git a/commands/helpers/run-with-keyring b/commands/helpers/run-with-keyring new file mode 100755 index 0000000..2925d2f --- /dev/null +++ b/commands/helpers/run-with-keyring @@ -0,0 +1,12 @@ +#!/bin/sh + +eval `gnome-keyring-daemon --start --components=secrets,pkcs11,ssh,gpg` + +export SSH_AUTH_SOCK +export GNOME_KEYRING_CONTROL +export GPG_AGENT_INFO +export GNOME_KEYRING_PID + +exec $1 + +kill $GNOME_KEYRING_PID diff --git a/commands/helpers/xinitrc b/commands/helpers/xinitrc new file mode 100644 index 0000000..9cb52c8 --- /dev/null +++ b/commands/helpers/xinitrc @@ -0,0 +1,58 @@ +unset GPG_AGENT_INFO +unset SSH_AUTH_SOCK +unset GNOME_KEYRING_CONTROL +unset GNOME_KEYRING_PID +unset SESSION_MANAGER + +HELPERS_DIR=`dirname "$0"` +COMMANDS_DIR=`dirname "$HELPERS_DIR"` +ROOT_DIR=`dirname "$COMMANDS_DIR"` + +if [ ! -z $SUGAR_PROFILE ]; then + grep -q PROFILE $ROOT_DIR/prefs + if [ $? -ne 0 ]; then + randomstring=`> $ROOT_DIR/prefs + fi +fi + +if [ -f $ROOT_DIR/prefs ]; then + source $ROOT_DIR/prefs +fi + +# Sugar doesn't handle multiple outputs properly. To avoid issues we keep the +# first output in the list returned by xrandr and turn off everything else. + +OUTPUTS=`$HELPERS_DIR/list-outputs` + +for output in $OUTPUTS +do + # Default to the first output in the list + if [ -z $OUTPUT ]; then + OUTPUT=$output + fi + + if [ $OUTPUT != $output ]; then + xrandr --output $output --off + fi +done + +if [ ! -z $RESOLUTION ]; then + xrandr -s $RESOLUTION +fi + +if [ ! -z $SUGAR_UI_TESTS ]; then + rm -rf ~/.sugar/ui-tests + export SUGAR_PROFILE=ui-tests +elif [ ! -z $PROFILE ]; then + export SUGAR_PROFILE=$PROFILE +fi + +if [ ! -z $SUGAR_XKBCONFIG ]; then + cat $SUGAR_XKBCONFIG | xkbcomp - $DISPLAY 2> /dev/null + rm $SUGAR_XKBCONFIG +fi + +RUN_COMMAND="dbus-launch --exit-with-session $HELPERS_DIR/run-with-keyring sugar" + +$COMMANDS_DIR/run-command $RUN_COMMAND -- cgit v0.9.1