Discuss Scratch

Shoheihei
Scratcher
3 posts

Cannot associate .sb2 file to scratch2.0 offline editor on Linux Ubuntu

I want to open scratch 2.0 offline editor by clicking .sb2 file, but now files are opened as a zip file.
If I launch scratch 2.0 offline editor first, then I can open .sb2 file through menu.

I installed Edubuntu 14.04.4 LTS to both 64bit PC and 32bit PC which both are installed scratch 2.0 offline editor but cannot open it from .sb2 file.

I have tried ways below already

1. from properties of .sb2 file.
-right click the file and choose properties
-select “Open With” tab
-cannot find Scratch 2.0 in Other Applications list

2. use Ubuntu-Tweak's file type manager
-install ubuntu-tweak_0.8.8-1
-launch Ubuntu Tweak
-select “Admins” tab
-choose “File Type Manager” under System
-choose Application Categories
-select “Zip archive (which is now .sb2 file's Type on properties)
-click Edit button
-click Add button
-”Use a custom command"
-Browse and select Scratch 2 in opt/Scratch 2/bin folder
-click open button
-no reaction for Add button or Cancel button

3.command
-open default.list by text editor
-change the line as below
application/zip=file-roller.desktop -> application/zip=Scratch\ 2.desktop

-open mimeapps.list
-change the line as below
application/zip=file-roller.desktop -> application/zip=Scratch\ 2.desktop

Could anyone help or see the same state?
IgDegOo
Scratcher
1000+ posts

Cannot associate .sb2 file to scratch2.0 offline editor on Linux Ubuntu

Here is a list of steps:
  1. open the offline editor
  2. select “Open” on the file menu
  3. choose the .sb2 file
If that doesn't work:
  1. get Windows
  2. that's it (no offense, but it's bound to work on that)
Shoheihei
Scratcher
3 posts

Cannot associate .sb2 file to scratch2.0 offline editor on Linux Ubuntu

Dear IgDegOo,

Thank you very much for the reply.
I can open .sb2 file by the way you mentioned. But I want to have second grade students in primary school play games on scratch to improve their calculation skill, so easier way is preferable that only double click a .sb2 file to open it.
There is a reason I want to use linux. I will distribute second-hand PCs to primary schools in rural area so using windows would urge me to pay a lot of cost…
iamjmm
New to Scratch
2 posts

Cannot associate .sb2 file to scratch2.0 offline editor on Linux Ubuntu

Hello

Did you find a way ?
I 've got the same problem.
Shoheihei
Scratcher
3 posts

Cannot associate .sb2 file to scratch2.0 offline editor on Linux Ubuntu

>iamjmm
Yes, I've found the solution.
Try this way below please (which is in my environment).

1. define .sb2 file's type
sudo vi /usr/share/mime/package/***.xml
*** is new file's name. Set is as you like. ex)scratch2
write text below in the file

<?xml version=“1.0” encoding=“UTF-8”?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info“>
<mime-type type=”application/x-scratch2“>
<comment></comment>
<glob pattern=”*.sb2“/>
</mime-type>
</mime-info>

2. associate .sb2 file with scratch 2 application
Find ”edu.media.mit.scratch2editor.desktop" file under directory of /usr/share/applications/ ,
and add only one line in the last line of that desktop file.
MimeType=application/x-scratch2

3. update
sudo update-desktop-databese
sudo update-mime-database

4. reboot PC
iamjmm
New to Scratch
2 posts

Cannot associate .sb2 file to scratch2.0 offline editor on Linux Ubuntu

Thanks (but unfortunately it failed on my computer, I'll try again)
mekizmo
Scratcher
51 posts

Cannot associate .sb2 file to scratch2.0 offline editor on Linux Ubuntu

Shoheihei wrote:

>iamjmm
Yes, I've found the solution.
Try this way below please (which is in my environment).

1. define .sb2 file's type
sudo vi /usr/share/mime/package/***.xml
*** is new file's name. Set is as you like. ex)scratch2
write text below in the file

<?xml version=“1.0” encoding=“UTF-8”?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info“>
<mime-type type=”application/x-scratch2“>
<comment></comment>
<glob pattern=”*.sb2“/>
</mime-type>
</mime-info>

2. associate .sb2 file with scratch 2 application
Find ”edu.media.mit.scratch2editor.desktop" file under directory of /usr/share/applications/ ,
and add only one line in the last line of that desktop file.
MimeType=application/x-scratch2

3. update
sudo update-desktop-databese
sudo update-mime-database

4. reboot PC

Thank you for your guide! This problem bothered me for a long time. Since I am almost illiterate in these matters and I mainly copypasted your solution, here's a few typos that caused me minor difficulties in the copypasting process:

- “/usr/share/mime/package/” should be “/usr/share/mime/packages/”;
- “sudo update-desktop-databese” should be “sudo update-desktop-database”;
- “sudo update-mime-database” should be “sudo update-mime-database /usr/share/mime”


— check out this and this
kcsaba
Scratcher
1 post

Cannot associate .sb2 file to scratch2.0 offline editor on Linux Ubuntu

Thank you @Shoheiei and @mekizmo for the description, I post a quick update here for future reference.

1. Define .sb2 file's type
$ sudo vi /usr/share/mime/packages/Scratch2.xml

add:
<?xml version=“1.0” encoding=“UTF-8”?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info“>
<mime-type type=”application/x-scratch2“>
<comment>Scratch 2 Application</comment>
<glob pattern=”*.sb2“/>
</mime-type>
</mime-info>

2. Associate .sb2 file with Scratch 2 application
$ sudo vi /usr/share/applications/edu.media.mit.scratch2editor.desktop

add one line to the end of the file:
MimeType=application/x-scratch2

3. Add mime type to application defaults
$ sudo vi /usr/share/applications/defaults.list

add anywhere in the file:
application/x-scratch2=edu.media.mit.scratch2editor.desktop

4. Update application and mime type database
$ sudo update-desktop-database (*)
$ sudo update-mime-database /usr/share/mime

*(A quick fix might be needed here, see the end of this comment if you se errors related to evince.desktop.)

5. Associate icons with Scratch project files
$ sudo ln -s /opt/Scratch\ 2/share/icons/ProjectIcon128.png /usr/share/icons/Humanity/mimes/128/application-x-scratch2.png
$ sudo ln -s /opt/Scratch\ 2/share/icons/ProjectIcon48.png /usr/share/icons/Humanity/mimes/48/application-x-scratch2.png
$ sudo ln -s /opt/Scratch\ 2/share/icons/ProjectIcon32.png /usr/share/icons/Humanity/mimes/32/application-x-scratch2.png
$ sudo ln -s /opt/Scratch\ 2/share/icons/ProjectIcon16.png /usr/share/icons/Humanity/mimes/16/application-x-scratch2.png

Upadte icon cache:
$ sudo gtk-update-icon-cache /usr/share/icons/Humanity -f

All done.

—–
Quick fix if needed:

If update-desktop-database report a bug in evince.desktop mime definition remove one semicolon from a double semicolon between mime types: “application/x-ext-cb7;;application/oxps;”

Error in file “/usr/share/applications/evince.desktop”: “” is an invalid MIME type (“” does not contain a subtype)
Error in file “/usr/share/applications/evince.desktop”: “” is an invalid MIME type (“” does not contain a subtype)

*https://bugzilla.redhat.com/show_bug.cgi?id=1471474

After fixing Go back to step 4. to update databases.
adaigio
Scratcher
1 post

Cannot associate .sb2 file to scratch2.0 offline editor on Linux Ubuntu

I am using ubuntu MATE 16.04. I have installed adobe air and scratch2. When I double click an sb2 file, scratch2 starts but it is blank and the scratch project which is in the sb2 file is not loaded. What can I do to open an sb2 scratch project with double click?

File: /usr/share/applications/scratch2.desktop

Encoding=UTF-8
Version=1.0
Type=Application
Exec=/opt/adobe-air-sdk/adobe-air/adobe-air /opt/adobe-air-sdk/scratch /Scratch-456.0.1.air
Icon=/opt/adobe-air-sdk/scratch/scratch.png
Terminal=false
Name=scratch2
Comment=Programming system and content development tool
Categories=Application;Education;Development;ComputerScience;
MimeType=application/scratch2project


File: /usr/share/mime/packages/scratchxml.xml
<?xml version=“1.0” encoding=“utf-8”?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info“>
<mime-type type=”application/scratch2project“>
<glob pattern=”*.sb2"/>
</mime-type>
</mime-info>

In the file /usr/share/applications/defaults.list I added the line:
application/scratch2project=scratch2.desktop


sudo chmod +x /usr/share/applications/scratch2.desktop
sudo update-desktop-database
sudo update-mime-database /usr/share/mime/

Last edited by adaigio (June 21, 2018 04:31:58)

Powered by DjangoBB