~martijnbraam/thumbdrives

2daca8ce932c60608f20cf7dac2f30dd39533398 — Martijn Braam 2 years ago d2e1dd7 0.2.0
Added icon and policykit styling
M data/meson.build => data/meson.build +4 -0
@@ 43,3 43,7 @@ endif
install_data('nl.brixit.Thumbdrives.policy',
  install_dir: join_paths(get_option('datadir'), 'polkit-1/actions')
)

install_data('nl.brixit.Thumbdrives.svg',
  install_dir: join_paths(get_option('datadir'), 'icons/hicolor/scalable/apps')
)

A data/nl.brixit.Thumbdrives.inkscape.svg => data/nl.brixit.Thumbdrives.inkscape.svg +170 -0
@@ 0,0 1,170 @@
<?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="128"
   height="128"
   viewBox="0 0 33.866666 33.866668"
   version="1.1"
   id="svg16866"
   sodipodi:docname="nl.brixit.Thumbdrives.scg.svg"
   inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
  <defs
     id="defs16860" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="0.7"
     inkscape:cx="-130.98522"
     inkscape:cy="214.19406"
     inkscape:document-units="mm"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:window-width="2560"
     inkscape:window-height="1403"
     inkscape:window-x="1920"
     inkscape:window-y="0"
     inkscape:window-maximized="1"
     units="px" />
  <metadata
     id="metadata16863">
    <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:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(0,-263.13332)">
    <rect
       style="opacity:1;fill:#b24e4e;fill-opacity:1;stroke:none;stroke-width:0.09948102;stroke-opacity:1"
       id="rect17428"
       width="9.6638708"
       height="19.04351"
       x="2.6776655"
       y="270.05746"
       rx="0.86327595"
       ry="0.78807771" />
    <rect
       style="opacity:1;fill:#d8a6a6;fill-opacity:1;stroke:none;stroke-width:0.09948102;stroke-opacity:1"
       id="rect17428-7"
       width="9.6638708"
       height="19.04351"
       x="2.6776626"
       y="268.10336"
       rx="0.86327595"
       ry="0.78807771" />
    <rect
       style="opacity:1;fill:#808080;fill-opacity:1;stroke:none;stroke-width:0.07994749;stroke-opacity:1"
       id="rect17472"
       width="5.9688616"
       height="3.7305388"
       x="4.5606971"
       y="288.37704" />
    <rect
       style="opacity:1;fill:#bfbfbf;fill-opacity:1;stroke:none;stroke-width:0.07994749;stroke-opacity:1"
       id="rect17472-5"
       width="5.9688616"
       height="3.7305388"
       x="4.5606942"
       y="287.57321" />
    <rect
       style="opacity:1;fill:#5b4eb2;fill-opacity:1;stroke:none;stroke-width:0.09948102;stroke-opacity:1"
       id="rect17428-3"
       width="9.6638708"
       height="19.04351"
       x="-109.44961"
       y="250.07745"
       rx="0.86327595"
       ry="0.78807771"
       transform="rotate(-26.653158)" />
    <rect
       style="opacity:1;fill:#5b4eb2;fill-opacity:1;stroke:none;stroke-width:0.09948102;stroke-opacity:1"
       id="rect17513"
       width="1.6520957"
       height="1.6698601"
       x="14.639814"
       y="271.2854" />
    <rect
       style="opacity:1;fill:#5b4eb2;fill-opacity:1;stroke:none;stroke-width:0.09948102;stroke-opacity:1"
       id="rect17513-9"
       width="1.6520957"
       height="1.6698601"
       x="29.615253"
       y="283.24759" />
    <rect
       style="opacity:1;fill:#a6a6d8;fill-opacity:1;stroke:none;stroke-width:0.09948102;stroke-opacity:1"
       id="rect17428-7-5"
       width="9.6638708"
       height="19.04351"
       x="-108.70633"
       y="248.60545"
       rx="0.86327595"
       ry="0.78807771"
       transform="rotate(-26.653158)" />
    <rect
       style="opacity:1;fill:#808080;fill-opacity:1;stroke:none;stroke-width:0.07994749;stroke-opacity:1"
       id="rect17472-6"
       width="5.9688616"
       height="3.7305388"
       x="-107.28116"
       y="268.68448"
       transform="rotate(-26.653158)" />
    <rect
       style="opacity:1;fill:#808080;fill-opacity:1;stroke:none;stroke-width:0.07664535;stroke-opacity:1"
       id="rect17530-1"
       width="1.2692062"
       height="0.78893143"
       x="30.386335"
       y="288.12634" />
    <rect
       style="opacity:1;fill:#808080;fill-opacity:1;stroke:none;stroke-width:0.07664535;stroke-opacity:1"
       id="rect17530"
       width="1.2692062"
       height="0.78893143"
       x="24.647467"
       y="287.46979" />
    <rect
       style="opacity:1;fill:#bfbfbf;fill-opacity:1;stroke:none;stroke-width:0.07994749;stroke-opacity:1"
       id="rect17472-5-2"
       width="5.9688616"
       height="3.7305388"
       x="-106.92725"
       y="267.97937"
       transform="rotate(-26.653158)" />
    <ellipse
       style="opacity:1;fill:#eb0000;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-opacity:1"
       id="path17547"
       cx="7.4414062"
       cy="277.29797"
       rx="2.952939"
       ry="7.4177828" />
    <ellipse
       style="opacity:1;fill:#0800eb;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-opacity:1"
       id="path17547-2"
       cx="-102.04119"
       cy="258.81879"
       rx="2.952939"
       ry="7.4177828"
       transform="rotate(-26.271055)"
       inkscape:transform-center-x="0.047247001" />
  </g>
</svg>

M data/nl.brixit.Thumbdrives.policy => data/nl.brixit.Thumbdrives.policy +27 -9
@@ 6,27 6,45 @@

  <vendor>Thumbdrives</vendor>

  <action id="nl.brixit.Thumbdrives.pkexec.mount">
    <message>Authentication is required to mount an image</message>
  <action id="nl.brixit.Thumbdrives.pkexec.mount-img">
    <description>Thumbdrive mounting</description>
    <message>Authentication is required to mount a thumbdrive</message>
    <icon_name>nl.brixit.Thumbdrives</icon_name>
    <defaults>
      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>auth_admin</allow_active>
      <allow_any>auth_admin_keep</allow_any>
      <allow_inactive>auth_admin_keep</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/pk-thumbdrive-action</annotate>
    <annotate key="org.freedesktop.policykit.exec.argv1">mount-mass-storage</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
  </action>

    <action id="nl.brixit.Thumbdrives.pkexec.umount">
  <action id="nl.brixit.Thumbdrives.pkexec.mount-iso">
    <description>Thumbdrive mounting</description>
    <message>Authentication is required to mount a CD image</message>
    <icon_name>nl.brixit.Thumbdrives</icon_name>
    <defaults>
      <allow_any>auth_admin_keep</allow_any>
      <allow_inactive>auth_admin_keep</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/pk-thumbdrive-action</annotate>
    <annotate key="org.freedesktop.policykit.exec.argv1">mount-iso</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
  </action>

  <action id="nl.brixit.Thumbdrives.pkexec.umount">
    <description>Thumbdrive unmounting</description>
    <message>Authentication is required to unmount an image</message>
    <icon_name>nl.brixit.Thumbdrives</icon_name>
    <defaults>
      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>auth_admin</allow_active>
      <allow_any>auth_admin_keep</allow_any>
      <allow_inactive>auth_admin_keep</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/pk-thumbdrive-action</annotate>
    <annotate key="org.freedesktop.policykit.exec.argv1">umount</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
  </action>


A data/nl.brixit.Thumbdrives.svg => data/nl.brixit.Thumbdrives.svg +142 -0
@@ 0,0 1,142 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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"
   id="svg16866"
   version="1.1"
   viewBox="0 0 33.866666 33.866668"
   height="128"
   width="128">
  <defs
     id="defs16860" />
  <metadata
     id="metadata16863">
    <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:Work>
    </rdf:RDF>
  </metadata>
  <g
     transform="translate(0,-263.13332)"
     id="layer1">
    <rect
       ry="0.78807771"
       rx="0.86327595"
       y="270.05746"
       x="2.6776655"
       height="19.04351"
       width="9.6638708"
       id="rect17428"
       style="opacity:1;fill:#b24e4e;fill-opacity:1;stroke:none;stroke-width:0.09948102;stroke-opacity:1" />
    <rect
       ry="0.78807771"
       rx="0.86327595"
       y="268.10336"
       x="2.6776626"
       height="19.04351"
       width="9.6638708"
       id="rect17428-7"
       style="opacity:1;fill:#d8a6a6;fill-opacity:1;stroke:none;stroke-width:0.09948102;stroke-opacity:1" />
    <rect
       y="288.37704"
       x="4.5606971"
       height="3.7305388"
       width="5.9688616"
       id="rect17472"
       style="opacity:1;fill:#808080;fill-opacity:1;stroke:none;stroke-width:0.07994749;stroke-opacity:1" />
    <rect
       y="287.57321"
       x="4.5606942"
       height="3.7305388"
       width="5.9688616"
       id="rect17472-5"
       style="opacity:1;fill:#bfbfbf;fill-opacity:1;stroke:none;stroke-width:0.07994749;stroke-opacity:1" />
    <rect
       transform="rotate(-26.653158)"
       ry="0.78807771"
       rx="0.86327595"
       y="250.07745"
       x="-109.44961"
       height="19.04351"
       width="9.6638708"
       id="rect17428-3"
       style="opacity:1;fill:#5b4eb2;fill-opacity:1;stroke:none;stroke-width:0.09948102;stroke-opacity:1" />
    <rect
       y="271.2854"
       x="14.639814"
       height="1.6698601"
       width="1.6520957"
       id="rect17513"
       style="opacity:1;fill:#5b4eb2;fill-opacity:1;stroke:none;stroke-width:0.09948102;stroke-opacity:1" />
    <rect
       y="283.24759"
       x="29.615253"
       height="1.6698601"
       width="1.6520957"
       id="rect17513-9"
       style="opacity:1;fill:#5b4eb2;fill-opacity:1;stroke:none;stroke-width:0.09948102;stroke-opacity:1" />
    <rect
       transform="rotate(-26.653158)"
       ry="0.78807771"
       rx="0.86327595"
       y="248.60545"
       x="-108.70633"
       height="19.04351"
       width="9.6638708"
       id="rect17428-7-5"
       style="opacity:1;fill:#a6a6d8;fill-opacity:1;stroke:none;stroke-width:0.09948102;stroke-opacity:1" />
    <rect
       transform="rotate(-26.653158)"
       y="268.68448"
       x="-107.28116"
       height="3.7305388"
       width="5.9688616"
       id="rect17472-6"
       style="opacity:1;fill:#808080;fill-opacity:1;stroke:none;stroke-width:0.07994749;stroke-opacity:1" />
    <rect
       y="288.12634"
       x="30.386335"
       height="0.78893143"
       width="1.2692062"
       id="rect17530-1"
       style="opacity:1;fill:#808080;fill-opacity:1;stroke:none;stroke-width:0.07664535;stroke-opacity:1" />
    <rect
       y="287.46979"
       x="24.647467"
       height="0.78893143"
       width="1.2692062"
       id="rect17530"
       style="opacity:1;fill:#808080;fill-opacity:1;stroke:none;stroke-width:0.07664535;stroke-opacity:1" />
    <rect
       transform="rotate(-26.653158)"
       y="267.97937"
       x="-106.92725"
       height="3.7305388"
       width="5.9688616"
       id="rect17472-5-2"
       style="opacity:1;fill:#bfbfbf;fill-opacity:1;stroke:none;stroke-width:0.07994749;stroke-opacity:1" />
    <ellipse
       ry="7.4177828"
       rx="2.952939"
       cy="277.29797"
       cx="7.4414062"
       id="path17547"
       style="opacity:1;fill:#eb0000;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-opacity:1" />
    <ellipse
       transform="rotate(-26.271055)"
       ry="7.4177828"
       rx="2.952939"
       cy="258.81879"
       cx="-102.04119"
       id="path17547-2"
       style="opacity:1;fill:#0800eb;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-opacity:1" />
  </g>
</svg>

M src/pk-thumbdrive-action.sh => src/pk-thumbdrive-action.sh +1 -1
@@ 68,7 68,7 @@ create_gadget () {

	# Mass storage function
	FUNCTION=$GADGET/functions/mass_storage.0
	LUN=$FUNCTION/lun.1
	LUN=$FUNCTION/lun.0
	mkdir $FUNCTION || echo "Could not create $FUNCTION"
	mkdir $LUN || echo "Could not create $LUN"


M src/vdisk.py => src/vdisk.py +1 -1
@@ 22,7 22,7 @@ def get_mounted():
    if raw.strip() == "":
        return None

    with open(gadget+"/functions/mass_storage.0/lun.1/file") as handle:
    with open(gadget+"/functions/mass_storage.0/lun.0/file") as handle:
        raw = handle.read()

    if raw.strip() == "":