Unverified Commit 93428225 authored by David Beniamine's avatar David Beniamine

Merge branch '56-orca' of gitlab.tetras-libre.fr:primtux-eole/grenoble/primtux-eole into Primtux4

parents 90d61896 a22c2eb8
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import yaml
import argparse
import os
import subprocess
import re
def find_desktop(name):
if not re.search(r'\.desktop$', name):
name = '{}.desktop'.format(name)
if os.path.exists(name):
return name
output = subprocess.run(['find', '/usr/share', '-name', name], stdout=subprocess.PIPE).stdout.decode()
return output.split("\n")[0]
def parse_desktop(desktop):
out = {}
with open(desktop) as f:
text = "\n".join(f.readlines())
p = re.compile(r'((Exec|Icon|Name=|Name\[fr\]|GenericName\[fr\]).*)')
matches = p.findall(text)
return {k: m.split("=")[1] for m, k in matches}
def add_to_handymenu(user, cmd, category):
path = '/etc/handymenu/handymenu-{}.default.yaml'.format(user)
subprocess.run(['sed', '-i', '-e', 's/!!python\/str//g', path])
with open(path) as stream:
yml = yaml.safe_load(stream)
except yaml.YAMLError as exc:
lastId = 0
found = alreadyIn = False
for app in yml:
lastId = max(app['id'], lastId)
if(app['name'] == category):
for launcher in app['apps']:
if(launcher['name'] == cmd['name']):
alreadyIn = True
launcher['cmd'] = cmd['cmd']
launcher['generic'] = cmd['generic']
launcher['icon'] = cmd['icon']
if(not alreadyIn):
app['apps'] += [cmd]
found = True
if(not found):
yml += [{
'apps': [cmd],
'name': category,
'id': lastId+1,
with open(path, 'w') as f:
yaml.dump(yml, f, default_flow_style=False, allow_unicode=True)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Add proggrams to handy menu.')
parser.add_argument('app', type=str, nargs=1, help='The app to add (name of a .desktop app or a path to the file)')
parser.add_argument('category', type=str, nargs=1, help='The name of the category in which add the app')
parser.add_argument('users', type=str, nargs='+', help='The users that should see the programm in their handy menu')
args = parser.parse_args()
print("Retrieving desktop file")
desktop = find_desktop(args.app[0])
print("parsing desktop info")
values = parse_desktop(desktop)
links = {
'Exec': 'cmd',
'GenericName': 'generic',
'GenericName[fr]': 'generic',
'Name[fr]': 'name',
'Name': 'name',
'Icon': 'icon',
cmd = {}
for k, v in links.items():
cmd[v] = values[k]
except KeyError:
for user in args.users:
print("Updating handymenu for {}".format(user))
add_to_handymenu(user, cmd, args.category[0])
DIR=$(realpath $(dirname $0))
USERS="01-mini 02-super 03-maxi prof"
if [ -z "$(dpkg -l | grep orca)" ]
apt-get update
apt-get install -y gnome-orca speech-dispatcher-espeak-ng python3-yaml
for u in $USERS
mkdir -p $confdir
cp $DIR/orca.conf $confdir/user-settings.conf
chown -R $u:$u $confdir
$DIR/add_to_handy_menu.py $DIR/orca.desktop "Accessibilité langue" mini maxi super prof
"pronunciations": {},
"profiles": {
"default": {
"voices": {
"default": {
"family": {
"dialect": null,
"name": "voix par d\u00e9faut espeak-ng",
"locale": "fr"
"system": {
"established": false
"hyperlink": {
"established": false
"uppercase": {
"average-pitch": 7.0
"speechServerFactory": "orca.speechdispatcherfactory",
"keybindings": {},
"speechServerInfo": [
"pronunciations": {},
"profile": [
"brailleContractionTable": "/usr/share/liblouis/tables/en-us-interline.ctb"
"keybindings": {},
"general": {
"enablePauseBreaks": true,
"enableFlashMessages": true,
"enableContractedBraille": false,
"speakCellSpan": true,
"enableBraille": true,
"enableSpeechIndentation": false,
"beepProgressBarUpdates": false,
"layoutMode": true,
"structNavTriggersFocusMode": false,
"speakCellCoordinates": true,
"presentToolTips": false,
"ignoreStatusBarProgressBars": true,
"speakNumbersAsDigits": false,
"enableTutorialMessages": false,
"structNavInSayAll": false,
"caretNavTriggersFocusMode": false,
"enableEchoByCharacter": false,
"enableBrailleMonitor": false,
"soundVolume": 0.5,
"brailleLinkIndicator": 192,
"chatAnnounceBuddyTyping": false,
"presentTimeFormat": "%X",
"playSoundForState": false,
"mouseDwellDelay": null,
"enableMnemonicSpeaking": false,
"brailleFlashTime": 5000,
"brailleContractionTable": "",
"flashIsDetailed": true,
"rewindAndFastForwardInSayAll": false,
"enableEchoByWord": false,
"brailleVerbosityLevel": 1,
"chatSpeakRoomName": false,
"verbalizePunctuationStyle": 1,
"findResultsVerbosity": 2,
"startingProfile": [
"playSoundForPositionInSet": false,
"keyboardLayout": 1,
"speakMultiCaseStringsAsWords": false,
"wrappedStructuralNavigation": true,
"skipBlankCells": false,
"enabledBrailledTextAttributes": "size:; family-name:; weight:400; indent:0; underline:none; strikethrough:false; justification:left; style:normal; text-spelling:none;",
"enableSpeech": true,
"speakMisspelledIndicator": true,
"enableMouseReview": false,
"enableSpace": true,
"disableBrailleEOL": false,
"orcaModifierKeys": [
"readFullRowInDocumentTable": true,
"speakProgressBarUpdates": true,
"readFullRowInGUITable": true,
"enableSound": true,
"brailleAlignmentStyle": 0,
"progressBarUpdateInterval": 10,
"textAttributesBrailleIndicator": 0,
"enablePositionSpeaking": false,
"speechServerInfo": null,
"enableBrailleContext": true,
"spellcheckPresentContext": true,
"profile": [
"speechVerbosityLevel": 1,
"messagesAreDetailed": true,
"structuralNavigationEnabled": true,
"chatMessageVerbosity": 0,
"enableDiacriticalKeys": false,
"onlySpeakDisplayedText": false,
"capitalizationStyle": "none",
"brailleRolenameStyle": 1,
"voices": {
"default": {
"established": false
"uppercase": {
"average-pitch": 7.0
"hyperlink": {
"established": false
"system": {
"established": false
"speechServerFactory": "speechdispatcherfactory",
"enableKeyEcho": true,
"speakSpreadsheetCoordinates": true,
"largeObjectTextLength": 75,
"findResultsMinimumLength": 4,
"enableModifierKeys": true,
"enabledSpokenTextAttributes": "size:; family-name:; weight:400; indent:0; underline:none; strikethrough:false; justification:left; style:normal; paragraph-style:; text-spelling:none; fg-color:; bg-color:;",
"brailleSelectorIndicator": 192,
"enableActionKeys": true,
"readFullRowInSpreadSheet": false,
"speakCellHeaders": true,
"enablePunctuationKeys": true,
"brailleProgressBarUpdates": false,
"enableAlphabeticKeys": true,
"enableNavigationKeys": false,
"progressBarVerbosity": 1,
"activeProfile": [
"playSoundForValue": false,
"chatRoomHistories": false,
"useColorNames": true,
"presentDateFormat": "%x",
"spellcheckSpellSuggestion": true,
"spellcheckSpellError": true,
"flashIsPersistent": false,
"speakBlankLines": true,
"enableEchoBySentence": false,
"enableFunctionKeys": true,
"playSoundForRole": false,
"enableNumericKeys": true,
"sayAllStyle": 1
[Desktop Entry]
GenericName[fr]=Lecteur d'écran
Exec=/usr/bin/orca --replace
......@@ -33,3 +33,4 @@ run_script fix_pcmanfm.sh
run_script fix_cups.sh
run_script fix_firefox.sh
run_script update_faces.sh
run_script install_orca.sh
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment