Skip to content

Commit

Permalink
Add swami changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbtylee committed Dec 9, 2019
1 parent 2b8bb4a commit 350999e
Show file tree
Hide file tree
Showing 17 changed files with 1,114 additions and 0 deletions.
9 changes: 9 additions & 0 deletions swami-control/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: swami-control
Version: 0.0.2bodhi17
Section: utils
Priority: optional
Architecture: all
Depends: python, python-efl, python-neet, python-elm-extensions, python-tz, python-dateutil, ntpdate
Maintainer: Robert Wiley <[email protected]>
Description: Swami Configuration Tool
An Elementary GUI for configuring the Moksha Desktop.
4 changes: 4 additions & 0 deletions swami-control/usr/bin/changetime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
#Usage: ./changetime.sh <date> <hours> <minutes> <seconds>
echo "changetime.sh"
date -s "${1} ${2}:${3}:${4}"
4 changes: 4 additions & 0 deletions swami-control/usr/bin/changetz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
#Usage: ./changetz.sh <new tz>
echo "changetz.sh"
cp -f /usr/share/zoneinfo/$1 /etc/localtime
49 changes: 49 additions & 0 deletions swami-control/usr/bin/convertimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
WP=$1
FNAME=$2

OUTPUT_DIR="$HOME/.e/e/backgrounds"

TEMPLATE='
images { image: "@IMAGE@" USER; }
collections {
group {
name: "e/desktop/background";
data { item: "style" "4"; item: "noanimation" "1"; }
max: @WIDTH@ @HEIGHT@;
parts {
part {
name: "bg";
mouse_events: 0;
description {
state: "default" 0.0;
aspect: @ASPECT@ @ASPECT@;
aspect_preference: NONE;
image { normal: "@IMAGE@"; scale_hint: STATIC; }
}
}
}
}
}
'

OFILE="$OUTPUT_DIR/$FNAME"

DIMENSION="$(identify -format "%w/%h" "$WP")"

if [ ! -z "$DIMENSION" ]; then
WIDTH=$(echo $DIMENSION | cut -d/ -f1)
HEIGHT=$(echo $DIMENSION | cut -d/ -f2)
IMAGE="$(echo "$WP" | sed 's/[^[:alnum:]_-]/\\&/g')"

if [ -z "$HEIGHT" -o "$HEIGHT" = "0" ]; then
ASPECT="0.0"
else
ASPECT=$(echo "scale=9; $DIMENSION" | bc)
fi
fi

printf "%s" "$TEMPLATE" | \
sed "s/@ASPECT@/$ASPECT/g; s/@WIDTH@/$WIDTH/g; s/@HEIGHT@/$HEIGHT/g; s|@IMAGE@|$IMAGE|g" > "$OFILE.edc"
edje_cc "$OFILE.edc" "$OFILE.edj" 2>/dev/null
rm "$OFILE.edc"
181 changes: 181 additions & 0 deletions swami-control/usr/bin/swami
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
#!/usr/bin/python
# encoding: utf-8

SwamiModuleDirectory = "/usr/lib/python2.7/dist-packages/"
#SwamiModuleDirectory = ""

#A rewrite of the E control panel in Python and Elementary for Moksha

import os
import sys
import importlib

from efl import ecore

from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
from efl import elementary
from efl.elementary.window import StandardWindow
from efl.elementary.icon import Icon
from efl.elementary.naviframe import Naviframe
from efl.elementary.box import Box
from efl.elementary.frame import Frame
from efl.elementary.button import Button
from efl.elementary.entry import Entry
from efl.elementary.scroller import Scroller

EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
FILL_HORIZ = EVAS_HINT_FILL, 0.5
ALIGN_CENTER = 0.5, 0.5

class MainWin(StandardWindow):
def __init__(self, launchArg):
# create the main window
StandardWindow.__init__(self, "swami", "Swami Control Panel",
autodel=True, size=(600, 400))
self.callback_delete_request_add(lambda o: elementary.exit())

#Make sure the dbus module is loaded. Changing Moksha settings needs this
ecore.Exe("enlightenment_remote -module-load msgbus")
ecore.Exe("enlightenment_remote -module-enable msgbus")

icon = Icon(self, size_hint_weight = EXPAND_BOTH, size_hint_align = FILL_BOTH)
icon.standard_set('preferences-system')
icon.show()
self.icon_object_set(icon)

self.modules = {}
self.launchArgs = {}

self.nf = Naviframe(self, size_hint_weight = EXPAND_BOTH, size_hint_align = FILL_BOTH)
self.nf.show()

searchFrame = Frame(self, size_hint_weight = EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
searchFrame.text = "Search"
searchFrame.show()

self.searchEntry = searchEntry = Entry(self, size_hint_weight = EXPAND_BOTH, size_hint_align=FILL_HORIZ)
searchEntry.single_line = True
searchEntry.callback_changed_add(self.searchTextUpdated)
searchEntry.show()

searchFrame.content = searchEntry

scr = Scroller(self, size_hint_weight = EXPAND_BOTH, size_hint_align = FILL_BOTH)
scr.show()

self.moduleBox = Box(self, size_hint_weight = EXPAND_BOTH, size_hint_align = FILL_BOTH)

scr.content = self.moduleBox

self.moduleSections = {}

self.loadModules()

self.configBox = Box(self, size_hint_weight = EXPAND_BOTH, size_hint_align = FILL_BOTH)
self.configBox.pack_end(searchFrame)
self.configBox.pack_end(scr)
self.configBox.show()

mainBox = Box(self, size_hint_weight = EXPAND_BOTH, size_hint_align = FILL_BOTH)
mainBox.pack_end(self.nf)
mainBox.show()

self.resize_object_add(mainBox)

self.returnMain()

if launchArg:
self.nf.item_simple_push(self.launchArgs[launchArg])

# show the window
self.show()

def searchTextUpdated(self, ourEntry):
#print ourEntry.text

if ourEntry.text:
for m in self.modules:
inSearch = False

for d in self.modules[m].searchData:
if ourEntry.text.lower() in d:
inSearch = True

if not inSearch:
#self.modules[m].button.hide()
self.modules[m].button.disabled = True
else:
self.modules[m].button.disabled = False
else:
for m in self.modules:
#self.modules[m].button.show()
self.modules[m].button.disabled = False

def loadModules(self):
modulesToLoad = []
if not SwamiModuleDirectory:
currentDir = os.listdir(".")
else:
currentDir = os.listdir(SwamiModuleDirectory)

for thing in currentDir:
if os.path.isdir("%s%s"%(SwamiModuleDirectory, thing)) and thing[:6] == "swami_":
modulesToLoad.append(thing)

#print modulesToLoad
for m in modulesToLoad:
imported = importlib.import_module(m)
self.modules[imported] = imported.SwamiModule(self)

if self.modules[imported].section not in self.moduleSections:
self.addModuleSection(self.modules[imported].section)

button = Button(self, size_hint_weight = EXPAND_BOTH, size_hint_align=FILL_HORIZ)
button.content_set(self.modules[imported].icon)
button.text = self.modules[imported].name
button.callback_clicked_add(self.modulePressed, self.modules[imported])
button.show()

self.modules[imported].button = button
self.launchArgs[self.modules[imported].launchArg] = self.modules[imported]

self.moduleSections[self.modules[imported].section].pack_end(button)

def addModuleSection(self, ourSection):
frame = Frame(self, size_hint_weight = EXPAND_BOTH, size_hint_align=FILL_HORIZ)
frame.text = ourSection
frame.autocollapse_set(True)
frame.show()

box = Box(self, size_hint_weight = EXPAND_BOTH, size_hint_align=FILL_HORIZ)
box.show()

frame.content = box

self.moduleBox.pack_end(frame)

self.moduleSections[ourSection] = box

def modulePressed(self, btn, module):
self.title = "Swami Control Panel - %s"%module.name
self.nf.item_simple_push(module)

def returnMain(self):
self.title = "Swami Control Panel"
self.nf.item_simple_push(self.configBox)

if __name__ == "__main__":
elementary.init()

if len(sys.argv) > 1:
launchArg = sys.argv[1]
else:
launchArg = None

app = MainWin(launchArg)

elementary.run()

elementary.shutdown()
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
KeyboardLayouts = { "English (US)" : "us",
"Afghani" : "af",
"Arabic" : "ara",
"Albanian" : "al",
"Armenian" : "am",
"German (Austria)" : "at",
"Azerbaijani" : "az",
"Belarusian" : "by",
"Belgian" : "be",
"Bangla" : "bd",
"Indian" : "in",
"Bosnian" : "ba",
"Portuguese (Brazil)" : "br",
"Bulgarian" : "bg",
"Arabic (Morocco)" : "ma",
"English (Cameroon)" : "cm",
"Burmese" : "mm",
"French (Canada)" : "ca",
"French (Democratic Republic of the Congo)" : "cd",
"Chinese" : "cn",
"Croatian" : "hr",
"Czech" : "cz",
"Danish" : "dk",
"Dutch" : "nl",
"Dzongkha" : "bt",
"Estonian" : "ee",
"Persian" : "ir",
"Iraqi" : "iq",
"Faroese" : "fo",
"Finnish" : "fi",
"French" : "fr",
"English (Ghana)" : "gh",
"French (Guinea)" : "gn",
"Georgian" : "ge",
"German" : "de",
"Greek" : "gr",
"Hungarian" : "hu",
"Icelandic" : "is",
"Hebrew" : "il",
"Italian" : "it",
"Japanese" : "jp",
"Kyrgyz" : "kg",
"Khmer (Cambodia)" : "kh",
"Kazakh" : "kz",
"Lao" : "la",
"Spanish (Latin American)" : "latam",
"Lithuanian" : "lt",
"Latvian" : "lv",
"Maori" : "mao",
"Montenegrin" : "me",
"Macedonian" : "mk",
"Maltese" : "mt",
"Mongolian" : "mn",
"Norwegian" : "no",
"Polish" : "pl",
"Portuguese" : "pt",
"Romanian" : "ro",
"Russian" : "ru",
"Serbian" : "rs",
"Slovenian" : "si",
"Slovak" : "sk",
"Spanish" : "es",
"Swedish" : "se",
"German (Switzerland)" : "ch",
"Arabic (Syria)" : "sy",
"Tajik" : "tj",
"Sinhala (phonetic)" : "lk",
"Thai" : "th",
"Turkish" : "tr",
"Taiwanese" : "tw",
"Ukrainian" : "ua",
"English (UK)" : "gb",
"Uzbek" : "uz",
"Vietnamese" : "vn",
"Korean" : "kr",
"Japanese (PC-98xx Series)" : "nec_vndr/jp",
"Irish" : "ie",
"Urdu (Pakistan)" : "pk",
"Dhivehi" : "mv",
"English (South Africa)" : "za",
"Esperanto" : "epo",
"Nepali" : "np",
"English (Nigeria)" : "ng",
"Amharic" : "et",
"Wolof" : "sn",
"Braille" : "brai",
"Turkmen" : "tm",
"Bambara" : "ml",
"Swahili (Tanzania)" : "tz",
"Swahili (Kenya)" : "ke",
"Tswana" : "bw",
"Filipino" : "ph",
"Moldavian" : "md" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#replace the * after swami_ with your module's name
from swami_keyboard import *
Loading

0 comments on commit 350999e

Please sign in to comment.