Browse Source

Initial commit

bryan 4 years ago
parent
commit
d07839b44b
8 changed files with 77 additions and 334 deletions
  1. 7 5
      README.md
  2. 0 148
      images/icon.svg
  3. 0 41
      images/rdp.svg
  4. 0 0
      images/ssh.svg
  5. 0 23
      images/vnc.svg
  6. 16 0
      images/x2goclient.svg
  7. 44 107
      main.py
  8. 10 10
      manifest.json

+ 7 - 5
README.md

@@ -1,9 +1,11 @@
-# ulauncher-remmina
+# ulauncher-x2goclient
 
-🖥 [Ulauncher](https://ulauncher.io) extension for quick access to [Remmina](https://remmina.org) profiles.
+🖥 [Ulauncher](https://ulauncher.io) extension for quick access to [x2goclient](https://wiki.x2go.org/doku.php) sessions.
 
-You can enter several queries to match strings in profiles' descriptions (e.g. `r ssh stan`)
+You can enter several queries to match strings in sessions' descriptions (e.g. `x ssh stan`)
 
-Some icons from the [Numix project](https://github.com/numixproject) and [Remmina](https://github.com/FreeRDP/Remmina).
+Icons from the [Numix project](https://github.com/numixproject).
 
-![ulauncher-remmina extension screenshot](screenshot.png)
+Adapted from [ulauncher-remmina](https://github.com/noam09/ulauncher-remmina) by noam09.
+
+![ulauncher-x2goclient extension screenshot](screenshot.png)

+ 0 - 148
images/icon.svg

@@ -1,148 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://creativecommons.org/ns#"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   width="444.66092"
-   height="444.66092"
-   viewBox="0 0 117.64988 117.64986"
-   version="1.1"
-   id="svg8"
-   inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
-   sodipodi:docname="icon_color.svg"
-   inkscape:export-filename="/home/anxhelo/works/Remmina/PNG/icon_color.png"
-   inkscape:export-xdpi="96"
-   inkscape:export-ydpi="96">
-  <defs
-     id="defs2" />
-  <sodipodi:namedview
-     id="base"
-     pagecolor="#ffffff"
-     bordercolor="#666666"
-     borderopacity="1.0"
-     inkscape:pageopacity="0"
-     inkscape:pageshadow="2"
-     inkscape:zoom="0.52467208"
-     inkscape:cx="102.72298"
-     inkscape:cy="224.46532"
-     inkscape:document-units="px"
-     inkscape:current-layer="g875"
-     inkscape:document-rotation="0"
-     showgrid="false"
-     borderlayer="true"
-     inkscape:showpageshadow="true"
-     units="px"
-     inkscape:pagecheckerboard="false"
-     showguides="true"
-     inkscape:window-width="1366"
-     inkscape:window-height="715"
-     inkscape:window-x="0"
-     inkscape:window-y="0"
-     inkscape:window-maximized="1"
-     objecttolerance="10"
-     guidetolerance="10"
-     inkscape:snap-tangential="true"
-     inkscape:snap-perpendicular="true"
-     fit-margin-top="0"
-     fit-margin-left="0"
-     fit-margin-right="0"
-     fit-margin-bottom="0">
-    <inkscape:grid
-       type="xygrid"
-       id="grid10"
-       dotted="false"
-       originx="-75.247744"
-       originy="-8.9404304" />
-  </sodipodi:namedview>
-  <metadata
-     id="metadata5">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-        <dc:title></dc:title>
-        <cc:license
-           rdf:resource="" />
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <g
-     inkscape:label="Layer 1"
-     inkscape:groupmode="layer"
-     id="layer1"
-     transform="translate(-75.247731,-170.4097)">
-    <g
-       id="g875"
-       transform="matrix(0.64508605,0,0,0.64508605,73.187616,170.4097)">
-      <g
-         id="g1019"
-         transform="matrix(2.3733304,0,0,2.3733304,3.19355,0)">
-        <g
-           id="g863">
-          <g
-             id="g855">
-            <polygon
-               style="fill:#20aa73"
-               class="st1"
-               points="20.618,17.742 20.618,26.923 29.549,32.877 20.618,38.831 20.618,48.012 43.32,32.877 "
-               id="polygon853" />
-          </g>
-          <g
-             id="g861">
-            <g
-               id="g859">
-              <polygon
-                 style="fill:#4a93dd"
-                 class="st2"
-                 points="55.388,59.232 55.388,50.051 46.457,44.097 55.388,38.143 55.388,28.962 32.685,44.097 "
-                 id="polygon857" />
-            </g>
-          </g>
-        </g>
-        <g
-           id="g873">
-          <g
-             id="g867">
-            <path
-               style="fill:#20aa73"
-               inkscape:connector-curvature="0"
-               class="st1"
-               d="m 64.776,23.074 c 2.632,4.509 4.147,9.75 4.147,15.348 0,16.845 -13.656,30.5 -30.5,30.5 -9.922,0 -18.734,-4.741 -24.304,-12.077 L 7.53,61.238 c 7.005,9.461 18.243,15.607 30.892,15.607 21.186,0 38.423,-17.236 38.423,-38.423 0,-7.215 -2.002,-13.97 -5.476,-19.744 z"
-               id="path865" />
-          </g>
-          <g
-             id="g871">
-            <path
-               style="fill:#4a93dd"
-               inkscape:connector-curvature="0"
-               class="st2"
-               d="m 7.922,38.423 c 0,-16.845 13.656,-30.5 30.5,-30.5 9.826,0 18.561,4.652 24.139,11.868 l 6.596,-4.397 C 62.142,6.053 50.976,0 38.423,0 17.236,0 0,17.236 0,38.423 0,45.543 1.954,52.212 5.343,57.936 L 11.937,53.54 C 9.387,49.083 7.922,43.925 7.922,38.423 Z"
-               id="path869" />
-          </g>
-        </g>
-      </g>
-    </g>
-  </g>
-  <style
-     id="style835"
-     type="text/css">
-	.st0{fill:#333333;}
-	.st1{fill:#20AA73;}
-	.st2{fill:#4A93DD;}
-</style>
-  <style
-     id="style905"
-     type="text/css">
-	.st0{fill:#333333;}
-	.st1{fill:#20AA73;}
-	.st2{fill:#4A93DD;}
-</style>
-</svg>

+ 0 - 41
images/rdp.svg

@@ -1,41 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">
- <defs>
-  <linearGradient id="linearGradient3764" x1="1" x2="47" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0,-1,1,0,-1.5e-6,47.999998)">
-   <stop style="stop-color:#e4e4e4;stop-opacity:1"/>
-   <stop offset="1" style="stop-color:#eee;stop-opacity:1"/>
-  </linearGradient>
- </defs>
- <g>
-  <path d="m 36.31 5 c 5.859 4.062 9.688 10.831 9.688 18.5 c 0 12.426 -10.07 22.5 -22.5 22.5 c -7.669 0 -14.438 -3.828 -18.5 -9.688 c 1.037 1.822 2.306 3.499 3.781 4.969 c 4.085 3.712 9.514 5.969 15.469 5.969 c 12.703 0 23 -10.298 23 -23 c 0 -5.954 -2.256 -11.384 -5.969 -15.469 c -1.469 -1.475 -3.147 -2.744 -4.969 -3.781 z m 4.969 3.781 c 3.854 4.113 6.219 9.637 6.219 15.719 c 0 12.703 -10.297 23 -23 23 c -6.081 0 -11.606 -2.364 -15.719 -6.219 c 4.16 4.144 9.883 6.719 16.219 6.719 c 12.703 0 23 -10.298 23 -23 c 0 -6.335 -2.575 -12.06 -6.719 -16.219 z" style="opacity:0.05"/>
-  <path d="m 41.28 8.781 c 3.712 4.085 5.969 9.514 5.969 15.469 c 0 12.703 -10.297 23 -23 23 c -5.954 0 -11.384 -2.256 -15.469 -5.969 c 4.113 3.854 9.637 6.219 15.719 6.219 c 12.703 0 23 -10.298 23 -23 c 0 -6.081 -2.364 -11.606 -6.219 -15.719 z" style="opacity:0.1"/>
-  <path d="m 31.25 2.375 c 8.615 3.154 14.75 11.417 14.75 21.13 c 0 12.426 -10.07 22.5 -22.5 22.5 c -9.708 0 -17.971 -6.135 -21.12 -14.75 a 23 23 0 0 0 44.875 -7 a 23 23 0 0 0 -16 -21.875 z" style="opacity:0.2"/>
- </g>
- <g>
-  <path d="m 24 1 c 12.703 0 23 10.297 23 23 c 0 12.703 -10.297 23 -23 23 -12.703 0 -23 -10.297 -23 -23 0 -12.703 10.297 -23 23 -23 z" style="fill:url(#linearGradient3764);fill-opacity:1"/>
- </g>
- <g>
-  <g>
-   <g transform="translate(1,1)">
-    <g style="opacity:0.1">
-     <!-- color: #eeeeee -->
-     <g>
-      <path d="m 11.531 13 c -0.297 0.031 -0.531 0.297 -0.531 0.594 l 0 10.816 c 0 0.316 0.277 0.594 0.594 0.594 l 5.406 0 l 0 2 l -4 0 l 0 2 l 7.281 0 l 0 -6 l -6.84 0 c -0.211 0 -0.41 -0.195 -0.41 -0.41 l 0 -7.184 c -0.004 -0.188 0.129 -0.371 0.313 -0.406 c 0.023 -0.004 0.066 -0.004 0.094 0 l 11.125 0 c 0.207 0 0.406 0.191 0.406 0.406 l 0 2.875 l 2.031 0 l 0 -4.691 c 0 -0.313 -0.281 -0.594 -0.594 -0.594 m -14.875 0" style="fill:#000;fill-opacity:1;stroke:none;fill-rule:nonzero"/>
-      <path d="m 21.535 19 c -0.293 0.031 -0.539 0.305 -0.539 0.598 l 0 10.809 c 0 0.313 0.289 0.598 0.602 0.598 l 5.398 0 l 0 2.992 l 4 0 l 0 -2.992 l 5.402 0 c 0.313 0 0.598 -0.285 0.598 -0.598 l 0 -10.809 c 0 -0.316 -0.289 -0.598 -0.598 -0.598 m -13.05 2 c 0.023 -0.004 0.047 -0.004 0.074 0 l 11.145 0 c 0.211 0 0.402 0.191 0.402 0.402 l 0 7.203 c 0 0.207 -0.191 0.398 -0.402 0.398 l -11.145 0 c -0.211 0 -0.402 -0.191 -0.402 -0.398 l 0 -7.203 c -0.004 -0.188 0.145 -0.367 0.328 -0.402 m -0.352 12 l 0 2 l 12 0 l 0 -2 m -12 0" style="fill:#000;fill-opacity:1;stroke:none;fill-rule:nonzero"/>
-     </g>
-    </g>
-   </g>
-  </g>
- </g>
- <g>
-  <g>
-   <!-- color: #eeeeee -->
-   <g>
-    <path d="m 11.531 13 c -0.297 0.031 -0.531 0.297 -0.531 0.594 l 0 10.816 c 0 0.316 0.277 0.594 0.594 0.594 l 5.406 0 l 0 2 l -4 0 l 0 2 l 7.281 0 l 0 -6 l -6.84 0 c -0.211 0 -0.41 -0.195 -0.41 -0.41 l 0 -7.184 c -0.004 -0.188 0.129 -0.371 0.313 -0.406 c 0.023 -0.004 0.066 -0.004 0.094 0 l 11.125 0 c 0.207 0 0.406 0.191 0.406 0.406 l 0 2.875 l 2.031 0 l 0 -4.691 c 0 -0.313 -0.281 -0.594 -0.594 -0.594 m -14.875 0" style="fill:#c0274b;fill-opacity:1;stroke:none;fill-rule:nonzero"/>
-    <path d="m 21.535 19 c -0.293 0.031 -0.539 0.305 -0.539 0.598 l 0 10.809 c 0 0.313 0.289 0.598 0.602 0.598 l 5.398 0 l 0 2.992 l 4 0 l 0 -2.992 l 5.402 0 c 0.313 0 0.598 -0.285 0.598 -0.598 l 0 -10.809 c 0 -0.316 -0.289 -0.598 -0.598 -0.598 m -13.05 2 c 0.023 -0.004 0.047 -0.004 0.074 0 l 11.145 0 c 0.211 0 0.402 0.191 0.402 0.402 l 0 7.203 c 0 0.207 -0.191 0.398 -0.402 0.398 l -11.145 0 c -0.211 0 -0.402 -0.191 -0.402 -0.398 l 0 -7.203 c -0.004 -0.188 0.145 -0.367 0.328 -0.402 m -0.352 12 l 0 2 l 12 0 l 0 -2 m -12 0" style="fill:#283751;fill-opacity:1;stroke:none;fill-rule:nonzero"/>
-   </g>
-  </g>
- </g>
- <g>
-  <path d="m 40.03 7.531 c 3.712 4.084 5.969 9.514 5.969 15.469 0 12.703 -10.297 23 -23 23 c -5.954 0 -11.384 -2.256 -15.469 -5.969 4.178 4.291 10.01 6.969 16.469 6.969 c 12.703 0 23 -10.298 23 -23 0 -6.462 -2.677 -12.291 -6.969 -16.469 z" style="opacity:0.1"/>
- </g>
-</svg>

File diff suppressed because it is too large
+ 0 - 0
images/ssh.svg


+ 0 - 23
images/vnc.svg

@@ -1,23 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">
- <defs>
-  <linearGradient id="linearGradient3764-6" x1="1" x2="47" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0,-1,1,0,-2e-6,47.999999)">
-   <stop style="stop-color:#e4e4e4;stop-opacity:1"/>
-   <stop offset="1" style="stop-color:#eee;stop-opacity:1"/>
-  </linearGradient>
- </defs>
- <g>
-  <path d="m 36.31,5 c 5.859,4.062 9.688,10.831 9.688,18.5 0,12.426 -10.07,22.5 -22.5,22.5 -7.669,0 -14.438,-3.828 -18.5,-9.688 1.037,1.822 2.306,3.499 3.781,4.969 4.085,3.712 9.514,5.969 15.469,5.969 12.703,0 23,-10.298 23,-23 0,-5.954 -2.256,-11.384 -5.969,-15.469 C 39.81,7.306 38.132,6.037 36.31,5 Z m 4.969,3.781 c 3.854,4.113 6.219,9.637 6.219,15.719 0,12.703 -10.297,23 -23,23 -6.081,0 -11.606,-2.364 -15.719,-6.219 4.16,4.144 9.883,6.719 16.219,6.719 12.703,0 23,-10.298 23,-23 0,-6.335 -2.575,-12.06 -6.719,-16.219 z" style="opacity:0.05"/>
-  <path d="m 41.28 8.781 c 3.712 4.085 5.969 9.514 5.969 15.469 0 12.703 -10.297 23 -23 23 -5.954 0 -11.384 -2.256 -15.469 -5.969 4.113 3.854 9.637 6.219 15.719 6.219 12.703 0 23 -10.298 23 -23 0 -6.081 -2.364 -11.606 -6.219 -15.719 z" style="opacity:0.1"/>
-  <path d="M 31.25,2.375 C 39.865,5.529 46,13.792 46,23.505 c 0,12.426 -10.07,22.5 -22.5,22.5 -9.708,0 -17.971,-6.135 -21.12,-14.75 a 23,23 0 0 0 44.875,-7 23,23 0 0 0 -16,-21.875 z" style="opacity:0.2"/>
- </g>
- <g>
-  <path d="M 24,1 C 36.703,1 47,11.297 47,24 47,36.703 36.703,47 24,47 11.297,47 1,36.703 1,24 1,11.297 11.297,1 24,1 Z" style="fill:url(#linearGradient3764-6);fill-opacity:1"/>
- </g>
- <g>
-  <path d="m 40.03,7.531 c 3.712,4.084 5.969,9.514 5.969,15.469 0,12.703 -10.297,23 -23,23 C 17.045,46 11.615,43.744 7.53,40.031 11.708,44.322 17.54,47 23.999,47 c 12.703,0 23,-10.298 23,-23 0,-6.462 -2.677,-12.291 -6.969,-16.469 z" style="opacity:0.1"/>
- </g>
- <path d="m 10.01 15 l 7.05 20.639 c 0.288 0.85 0.94 1.366 1.811 1.359 c 0.865 -0.005 1.498 -0.515 1.781 -1.359 l 7.02 -20.639 l -3.779 0 l -5.04 15.68 l -5.117 -15.68 l -3.729 0 z m 22.99 0 c -2.77 0 -5 2.23 -5 5 l 0 5 l 3 0 l 0 -5 c 0 -1.108 0.892 -2 2 -2 c 1.108 0 2 0.892 2 2 l 0 5 l 3 0 l 0 -5 c 0 -2.77 -2.23 -5 -5 -5 z m 0 12 c -2.77 0 -5 2.23 -5 5 c 0 2.77 2.23 5 5 5 l 5 0 l 0 -3 l -5 0 c -1.108 0 -2 -0.892 -2 -2 c 0 -1.108 0.892 -2 2 -2 l 5 0 l 0 -3 l -5 0 z" style="fill:#000;opacity:0.1;fill-opacity:1;stroke:none;fill-rule:evenodd"/>
- <path d="m 9 14 3.738 0 5.117 15.679 5.04 -15.679 3.778 0 -7.02 20.638 c -0.283 0.844 -0.917 1.356 -1.782 1.361 -0.871 0.007 -1.523 -0.511 -1.811 -1.361 l -7.05 -20.638" style="fill:#f13e3e;fill-opacity:1;stroke:none;fill-rule:evenodd"/>
- <path d="m 32 14 c -2.77 0 -5 2.23 -5 5 l 0 5 3 0 0 -5 c 0 -1.108 0.892 -2 2 -2 1.108 0 2 0.892 2 2 l 0 5 3 0 0 -5 c 0 -2.77 -2.23 -5 -5 -5 z" style="fill:#49d74a;opacity:1;fill-opacity:1;stroke:none"/>
- <path d="m 27 31 c 0 2.77 2.23 5 5 5 l 5 0 0 -3 -5 0 c -1.108 0 -2 -0.892 -2 -2 0 -1.108 0.892 -2 2 -2 l 5 0 0 -3 -5 0 c -2.77 0 -5 2.23 -5 5 z" style="fill:#4747d8;opacity:1;fill-opacity:1;stroke:none"/>
-</svg>

+ 16 - 0
images/x2goclient.svg

@@ -0,0 +1,16 @@
+<svg version="1.1" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
+ <defs>
+  <linearGradient id="bg" x2="0" y1="1" y2="47" gradientUnits="userSpaceOnUse">
+   <stop style="stop-color:#99c1fb" offset="0"/>
+   <stop style="stop-color:#85b5fa" offset="1"/>
+  </linearGradient>
+ </defs>
+ <path d="m36.31 5c5.859 4.062 9.688 10.831 9.688 18.5 0 12.426-10.07 22.5-22.5 22.5-7.669 0-14.438-3.828-18.5-9.688 1.037 1.822 2.306 3.499 3.781 4.969 4.085 3.712 9.514 5.969 15.469 5.969 12.703 0 23-10.298 23-23 0-5.954-2.256-11.384-5.969-15.469-1.469-1.475-3.147-2.744-4.969-3.781zm4.969 3.781c3.854 4.113 6.219 9.637 6.219 15.719 0 12.703-10.297 23-23 23-6.081 0-11.606-2.364-15.719-6.219 4.16 4.144 9.883 6.719 16.219 6.719 12.703 0 23-10.298 23-23 0-6.335-2.575-12.06-6.719-16.219z" style="opacity:.05"/>
+ <path d="m41.28 8.781c3.712 4.085 5.969 9.514 5.969 15.469 0 12.703-10.297 23-23 23-5.954 0-11.384-2.256-15.469-5.969 4.113 3.854 9.637 6.219 15.719 6.219 12.703 0 23-10.298 23-23 0-6.081-2.364-11.606-6.219-15.719z" style="opacity:.1"/>
+ <path d="m31.25 2.375c8.615 3.154 14.75 11.417 14.75 21.13 0 12.426-10.07 22.5-22.5 22.5-9.708 0-17.971-6.135-21.12-14.75a23 23 0 0 0 44.875-7 23 23 0 0 0-16-21.875z" style="opacity:.2"/>
+ <circle cx="24" cy="24" r="23" style="fill:url(#bg)"/>
+ <path d="m13 15v2h9v-2zm11 0v1h1.5l4 9-4.5 9h-1v1h4v-1h-1.5l3.6992-7.4004 3.3008 7.4004h-1.5v1h5v-1h-1l-4.4004-10 3.9004-8h1.5v-1h-5v1h2l-3.1758 6.3535-2.8242-6.3535h2v-1zm-11 3v2h12.09l-0.88867-2h-2.2012zm0 3v2h13.424l-0.88867-2zm0 3v2h13.764l0.52539-1.0508-0.42187-0.94922zm0 3v2h12.264l1-2zm0 3v2h10.764l1-2zm0 3v2h9v-2z" style="opacity:.1;paint-order:normal"/>
+ <path d="m40.03 7.531c3.712 4.084 5.969 9.514 5.969 15.469 0 12.703-10.297 23-23 23-5.954 0-11.384-2.256-15.469-5.969 4.178 4.291 10.01 6.969 16.469 6.969 12.703 0 23-10.298 23-23 0-6.462-2.677-12.291-6.969-16.469z" style="opacity:.1"/>
+ <path d="m23 14v1h1.5l4 9-4.5 9h-1v1h4v-1h-1.5l3.7-7.3998 3.3 7.3998h-1.5v1h5v-1h-1l-4.4-9.9998 3.9-8.0002h1.5v-1h-5v1h2l-3.1758 6.3535-2.8242-6.3535h2v-1z" style="fill:#484848;paint-order:normal"/>
+ <path d="m12 14v2h9v-2h-9zm0 3v2h12.09l-0.88867-2h-2.2012-9zm0 3v2h13.424l-0.88867-2h-12.535zm0 3v2h13.764l0.52539-1.0508-0.42187-0.94922h-13.867zm0 3v2h12.264l1-2h-13.264zm0 3v2h9 1.7637l1-2h-11.764zm0 3v2h9v-2h-9z" style="fill:#484848;paint-order:normal"/>
+</svg>

+ 44 - 107
main.py

@@ -27,77 +27,69 @@ if os.path.exists(usage_db):
         # JSON to dict
         usage_cache = json.loads(raw)
 
-# Initialize items cache and Remmina profiles path
-remmina_bin = ""
-# Locate Remmina profiles and binary
-default_paths = ["{}/.local/share/remmina".format(os.environ.get('HOME')),
-                 "{}/.remmina".format(os.environ.get('HOME'))]
-# remmina_profiles_path = "{}/.local/share/remmina".format(os.environ.get('HOME'))
-# remmina_profiles_path_alt = "{}/.remmina".format(os.environ.get('HOME'))
-remmina_bin = distutils.spawn.find_executable('remmina')
-# This extension is useless without remmina
-if remmina_bin is None or remmina_bin == "":
-    logger.error("Remmina executable path could not be determined")
+# Initialize items cache and x2goclient sessions file path
+x2goclient_bin = ""
+# Locate x2goclient profiles and binary
+x2go_sessions_path = ["{}/.x2goclient/sessions".format(os.environ.get('HOME'))]
+x2goclient_bin = distutils.spawn.find_executable('x2goclient')
+# This extension is useless without x2goclient
+if x2goclient_bin is None or x2goclient_bin == "":
+    logger.error("x2goclient executable path could not be determined")
     exit()
-# Check if Remmina profiles directory exists
-remmina_profiles_path = None
+# Check if x2goclient sessions file exists
+x2go_sessions_path_exists = None
 # Check default paths first
-for p in default_paths:
-    if os.path.isdir(p):
-        remmina_profiles_path = p
+if os.path.isfile(x2go_sessions_path):
+    x2go_sessions_path_exists = True
 
 
-class RemminaExtension(Extension):
+class x2goclientExtension(Extension):
     def __init__(self):
 
-        super(RemminaExtension, self).__init__()
+        super(x2goclientExtension, self).__init__()
         self.subscribe(KeywordQueryEvent, KeywordQueryEventListener())
         self.subscribe(ItemEnterEvent, ItemEnterEventListener())
 
-    def list_profiles(self, query):
-        profiles = []
-        items_cache = []
-        try:
-            # Get list of profile files from Remmina directory
-            for profile in os.listdir(remmina_profiles_path):
-                if profile.endswith(".remmina"):
-                    profiles.append(os.path.join(remmina_profiles_path, profile))
-            # Get sorted list of profiles
-            temp = profiles
-            profiles = sorted(temp)
-        except Exception as e:
-            logger.error("Failed getting Remmina profile files")
-        for p in profiles:
-            base = os.path.basename(p)
-            title, desc, proto = profile_details(p)
+    def list_sessions(self, query):
+        items = []
+        with open('/home/bryan/.x2goclient/sessions') as lines:
+            for line in lines:
+                if line.startswith('host=') or line.startswith('name='):
+                    line = line.rstrip()
+                    line = line.split('=',1)
+                    item = line[1]
+                    items.append(item)
+        it_items = iter(items)
+        sessions = list(zip(it_items, it_items))
+        for session in sessions:
+            host = session[0]
+            name = session[1]
             # Search for query inside filename and profile description
             # Multiple strings can be used to search in description
             # all() is used to achieve a AND search (include all keywords)
             keywords = query.split(" ")
             # if (query in base.lower()) or (query in desc.lower()):
-            if (query.lower() in base.lower()) or \
-               (query.lower() in title.lower()) or \
-               all(x.lower() in desc.lower() for x in keywords):
-                items_cache.append(create_item(title, proto, p, desc, p))
+            if (query.lower() in host.lower()) or (query.lower() in name.lower()):
+                items_cache.append(create_item(host, name))
 
         items_cache = sorted(items_cache, key=sort_by_usage, reverse=True)
         return items_cache
 
 
+
 class KeywordQueryEventListener(EventListener):
     def on_event(self, event, extension):
-        global remmina_profiles_path
-        if extension.preferences["profiles"] is not "" \
-           or not remmina_profiles_path:
+        global x2go_sessions_path
+        if extension.preferences["sessions"] is not "" or not x2go_sessions_path:
             # Tilde (~) won't work alone, need expanduser()
-            remmina_profiles_path = os.path.expanduser(extension.preferences["profiles"])
-        # pref_profiles_path = extension.preferences['profiles']
-        logger.debug("Remmina profiles path: {}".format(remmina_profiles_path))
+            x2go_sessions_path = os.path.expanduser(extension.preferences["sessions"])
+        # pref_sessions_path = extension.preferences['sessions']
+        logger.debug("x2goclient sessions path: {}".format(x2go_sessions_path))
         # Get query
         term = (event.get_argument() or "").lower()
         # Display all items when query empty
-        profiles_list = extension.list_profiles(term)
-        return RenderResultListAction(profiles_list[:8])
+        sessions_list = extension.list_sessions(term)
+        return RenderResultListAction(sessions_list[:8])
 
 
 class ItemEnterEventListener(EventListener):
@@ -117,16 +109,16 @@ class ItemEnterEventListener(EventListener):
         # Update usage JSON
         with open(usage_db, 'w') as db:
             db.write(json.dumps(usage_cache, indent=2))
-        return RunScriptAction('#!/usr/bin/env bash\n{} -c {}\n'.format(remmina_bin, on_enter), None).run()
+        return RunScriptAction('#!/usr/bin/env bash\n{} --session {}\n'.format(x2goclient_bin, on_enter), None).run()
 
 
-def create_item(name, icon, keyword, description, on_enter):
+def create_item(host, name):
     return ExtensionResultItem(
             name=name,
-            description=description,
-            icon="images/{}.svg".format(icon),
+            description=host,
+            icon="images/x2goclient.svg",
             on_enter=ExtensionCustomAction(
-                 {"id": on_enter})
+                 {"id": name})
             )
 
 
@@ -141,61 +133,6 @@ def sort_by_usage(i):
     return 0
 
 
-def profile_details(profile_path):
-    if os.path.isfile(profile_path):
-        with open(profile_path, "r") as f:
-            # Read profile file lines
-            lines = f.read().split("\n")
-            # Initialize strings
-            desc = name = username = group = proto = ""
-            # Parse lines for relevant details
-            for line in lines:
-                # Profile name
-                if line.startswith("name="):
-                    elem = line.split("name=")
-                    if len(elem[1]) > 0:
-                        name = elem[1]
-                # Profile username (optional)
-                if "username=" in line:
-                    elem = line.split("username=")
-                    # if len(elem) > 1:
-                    if len(elem[0]) == 0 and len(elem[1]) > 0:
-                        username = elem[1]
-                    elif len(elem[0]) > 0 and len(elem[1]) > 0:
-                        username = elem[1]
-                # Profile server and port
-                if line.startswith("server="):
-                    elem = line.split("server=")
-                    if len(elem[1]) > 0:
-                        server = elem[1]
-                # Profile group name
-                if line.startswith("group="):
-                    elem = line.split("group=")
-                    if len(elem[1]) > 0:
-                        group = elem[1]
-                # Profile protocol (for different icons)
-                if line.startswith("protocol="):
-                    elem = line.split("protocol=")
-                    if len(elem[1]) > 0:
-                        proto = elem[1].strip().lower()
-                else:
-                    pass
-            if len(username) > 0:
-                server = "{username}@{server}".format(username=username,
-                                                      server=server)
-            if len(proto) > 0:
-                server = "{proto}://{server}".format(proto=proto,
-                                                     server=server)
-            if len(group) > 0:
-                group = " | {group}".format(group=group)
-            # Final description string
-            desc = "{server} {group}".format(server=server,
-                                             group=group)
-            return name, desc, proto
-    else:
-        # Default values
-        return "", "", "rdp"
-
 
 if __name__ == "__main__":
-    RemminaExtension().run()
+    x2goclientExtension().run()

+ 10 - 10
manifest.json

@@ -1,25 +1,25 @@
 {
   "required_api_version": "^2.0.0",
-  "name": "Remmina",
-  "description": "Quick access to Remmina profiles",
-  "developer_name": "noam09",
+  "name": "x2goclient",
+  "description": "Quick access to x2goclient sessions",
+  "developer_name": "cryobry",
   "icon": "images/icon.svg",
   "options": {
     "query_debounce": 0.1
   },
   "preferences": [
     {
-      "id": "remmina",
+      "id": "x2goclient",
       "type": "keyword",
-      "name": "Remmina",
-      "description": "Quick access to Remmina profiles",
-      "default_value": "r"
+      "name": "x2goclient",
+      "description": "Quick access to x2goclient sessions",
+      "default_value": "x"
     },
     {
-      "id": "profiles",
+      "id": "sessions",
       "type": "input",
-      "name": "Remmina Profiles Directory",
-      "description": "Where Remmina stores profile configuration files <br /><code>~/.local/share/remmina</code> and <code>~/.remmina</code> are checked by default",
+      "name": "x2goclient sessions file",
+      "description": "Where x2goclient stores its profile configuration file <br /><code>~/.x2goclient/sessions</code> is checked by default",
       "default_value": ""
     }
   ]

Some files were not shown because too many files changed in this diff