Ubuntu OS App runtime enviroment

Source: Internet
Author: User
Tags i18n git clone

In this post. We will introduce the Ubuntu OS Runtime environment. In the article "app confinement:security policy for click Packages", we see that it has a runtime environment that describes an application. Here, let's take a sample to show how an application's runtime environment really is.


Here we can refer to my previous article "C + + and QML hybrid programming on Ubuntu", which we download in the article:


BZR Branch lp:~liu-xiao-guo/debiantrial/readenv


By entering the above sentences in a terminal, you can download the software from the routines.

At the same time, we make changes to our main program file "READENV.QML" such as the following:


Import QtQuick 2.0import ubuntu.components 0.1import Ubuntu.Components.ListItems 0.1 as Listitemimport readenv 1.0import    "UI"/*!           \brief MainView with Tabs element.  First Tab have a single Label and second Tab have a single Toolbaraction.*/mainview {id:root//ObjectName For functional testing purposes (AUTOPILOT-QT5) ObjectName: "MainView"//note! ApplicationName needs to match the "name" field of the click Manifest ApplicationName: "Com.ubuntu.developer.liu-xiao-g Uo. Readenv "anchortokeyboard:true/* This property enables the application-change orientation when the Devi CE is rotated.    The default is False. * *//automaticorientation:true Width:units.gu (height:units.gu) property string App_pkgname Readen v {id:readenv} flickable {id:scrollwidget anchors.fill:parent contentheight:conte NtItem.childrenRect.height boundsbehavior: (Contentheight > Root.height)? 

Flickable.DragAndOvershootBounds:Flickable.StopAtBounds/* Set the direction to workaround https://bugreports.qt -project.org/browse/qtbug-31905 otherwise the UI might end up in a situation where scrolling doesn ' t work */ FlickableDirection:Flickable.VerticalFlick Column {anchors.left:parent.left Anchors.ri Ght:parent.right listitem.base {height:ubuntuLabel.height + runtime.height + units.gu (6) Column {anchors.left:parent.left Anchors.right:parent.right Anchors.centerIn:parent Spacing:units.gu (2) Label { Id:ubuntulabel anchors.horizontalCenter:parent.horizontalCenter text: "? "FontSize:" X-large "} Label {Id:ru Ntime Anchors.horizontalCenter:parent.horizontalCenter text: "Runtime Environment" }}} listitem.subtitled {text:i18n.tr ("Ubuntu_application_isolat ION ") subText:readEnv.getenv (" Ubuntu_application_isolation ")} listitem.subtitled { text:i18n.tr ("app_id") subText:readEnv.getenv ("app_id")} LISTITEM.S ubtitled {text:i18n.tr ("Xdg_cache_home") subText:readEnv.getenv ("Xdg_cache_home") } listitem.subtitled {text:i18n.tr ("Xdg_config_home") subText:readEnv.gete NV ("Xdg_config_home")} listitem.subtitled {text:i18n.tr ("Xdg_data_home") SubText:readEnv.getenv ("Xdg_data_home")} listitem.subtitled {text:i18n.tr (" Xdg_runtime_dir ") SubText:readEnv.getenv ("Xdg_runtime_dir")} listitem.subtitled {text:i18n . TR ("TMPDIR") subText:readEnv.getenv ("TMPDIR")} listitem.subtitled { text:i18n.tr ("pwd") subText:readEnv.getenv ("pwd")} listitem.subtitled { text:i18n.tr ("App_pkgname") Subtext:app_pkgname} listitem.subtitled { text:i18n.tr ("path") subText:readEnv.getenv ("Path")} listitem.subtitled { text:i18n.tr ("Ld_library_path") subText:readEnv.getenv ("Ld_library_path")} listitem.subtitled {text:i18n.tr ("Qml2_import_path") subText:readEnv.getenv ("QML 2_import_path ")}}} component.oncompleted: {var app_id = readenv.getenv (" app_id "); Console.log ("app_id:" + app_id); App_pkgname = App_id.split ('_') [0] Console.log ("App_pkgname:" + app_pkgname); }}


We were able to read the application's environment variables through the READENV library we designed.

To execute our program. Show demo samples such as the following:


watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvvwj1bnr1vg91y2g=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "width=" "height=" >


In the article, it mentions such as the following folder, which should have read and Write permissions:


    • Xdg_cache_home/<app_pkgname>
    • Xdg_config_home/<app_pkgname>
    • Xdg_data_home/<app_pkgname>
    • Xdg_runtime_dir/<app_pkgname>
    • Xdg_runtime_dir/confined/<app_pkgname> (for TMPDIR)
For our applications. That is, for example, the following folder has read and Write permissions:

    • /home/phablet/.cache/com.ubuntu.developer.liu-xiao-guo.readenv
    • /home/phablet/.config/com.ubuntu.developer.liu-xiao-guo.readenv
    • /home/phablet/.local/share/com.ubuntu.developer.liu-xiao-guo.readenv
    • /run/user/32011/confined/com.ubuntu.developer.liu-xiao-guo.readenv

The source code for the entire program can be found in the following address:

BZR BranchLP:~LIU-XIAO-GUO/DEBIANTRIAL/RUNTIMEEVN

a more complete routine in: Git clone https://gitcafe.com/ubuntu/runtimeenv.git
Notice that in the new routine. We can use readenv.getenv or readenv.getenv1 two ways to get the value of an environment variable at the same time.



Ubuntu OS App runtime enviroment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.