Bind mount

Flatpak and snap becomes more and more popular. One of the reasons is that it is possible to do sandboxing. Which may give issues, if you need access to something outside the sandbox.
I have a nextcloud server running in snap, and it works great. However my OS and apps runs in a relative small SSD disk, so there isn’t much storage in my cloud. I have a couple of 3 TByte disks in the same server, and would like that to hold my cloud storage.
The documentation on how to add external storage to the Nextcloud was not good, or I was to sleepy, so I was investigating how to circumvent the snap sandbox.

Tada – bind mount came to my rescue.
For testing you can do the mount directly from the CLI:
$sudo mount –bind <Source directory> <Mount point>

And after verifying that it works, you want to change your fstab:
<source directory> <mount point> none defaults,bind 0 0

The mount point should be inside your snap sandbox e.g. /var/snap/nextcloud/common/nextcloud/data

In the good old days it was possible to hard link directories, but modern linux’es seems to have abandoned the philosophy “If you want to shoot yourself in the foot – go ahead and do so”, so it is no longer possible to do this.
But there you can use the bind mount.
Just installed the jellyfin media server, and my music collection is buried below my nextcloud files.
But since the jellyfin runs as another user, it cannot see anything within my home directory:
I made a directory: /media/Music and made a bind mount:
$sudo mount –bind /home/myuser/Nextcloud/Music /media/Music
And now the media server had access to all my music



Posted in Uncategorized | Leave a comment

SQLite and arrays

So I decided to go for sqlite as a database for my projects.
Reason for this was I wouldn’t like the customer to install a database like MariaDB, or have to fight an IT departement to create a new database.
My app should – and will be – self contained,

But during the work, I found that SQLite does not support arrays. Why! Who could think of any database without arrays!
Well I stick to my decision – just make coding a little more tedious!

Sigh!

Posted in Uncategorized | Leave a comment

Jellyfin and Sonos

I have a couple of Sonos speakers, and I am quite happy with them. I do not have a windows box, but I manage them from my android apps, and from Noson on my linux box. Big kudos to the person behind the Noson app – it works really great.
However the changes Sonos made, first med my music collection unsearchable, and after they have fixed that, then the new inde is impossible – Albums with different artists will have one entry per artist.
Looking around, I decided to try Jellyfin media server, although it seems there has been issues getting it to work with Sonos.
Installing Jellyfin was easy, and after a couple of permission issues, it could also scan my music collection.
I installed it on my laptop, just to see if it worked, and it worked great. It natively found my Sonos speakers, and even found my Samsung TV. Great!
So no I can use Jellyfin as a media player on my laptop, which runs linux mint 21.3.
Decided to put it on my server instead, and did so. But now it could not see any DLNA devices. My server runs mint 20 – so that could be the problem.
Should I upgrade my server, which also runs Nextcloud and Piwigo? – or should I just use Jellyfin as a media player?
Seems I have some decisions to make.
Posted in Uncategorized | Leave a comment

RSS feeds on linux vs. Flipboard

So my Samsung tablet died last week. So I decided to use my linux laptop and my phone, instead of buying a new laptop.
So far is the only thing I really miss Flipboard.
Looking for alternatives, I finally decided to turn to RSS, which I for unknown reasons have avoided in the past.
Looked at a couple of OpenSource readers, and finally decided for fluent reader

Now the problem was to find some feeds. Googled for it and found a couple of hints.

Try the URL followed by /feed or /rss – https://www.tv4.se/rss
On the web page list the source, and search for rss. – works for this blog: https://vgdata.dk/blog/?feed=rss2
Or simple google for the URL and rss

Now I have better feeds than I used to in flipboard, because I have all my local news.
Just needs to get used to the different format.

Posted in Uncategorized | Leave a comment

Lazarus and git

Lazarus hasn’t any integrated code version tool implemented.
I like git and uses github for my projects.
So I installed git-gui from the software center.
After that I went to Tools -> Configure external tools in lazarus, and added the folowing:

After that I can simply commit and push my changes by selecting git in the tools menu.

Posted in Uncategorized | Leave a comment

Start tmux automatically when connecting via SSH

tmux is a beautiful terminal application, which is able to survive disconnections.
But I ofte forget to start it, when I connect to a server via SSH.
I found this solution on the internet, unfortunately I cannot remember where, so I cannot give kredit to the originator.
However: put this at the end of your bashrc, ant it will start a tmux session, if one doesn’t exists, and connect to a session that already exists.

if [[ -n “${SSH_TTY}” ]] && [[ “${TERM}” != “tmux-256color” ]]; then tmux attach || tmux && exit
fi

Posted in Uncategorized | Leave a comment

LocalSend – a replacement for KConnect airdrop and more

Thanks to a post in “IT’S FOSS” I heard about localsend.
I have struggled with transferring files between my phone and my workstation.
Tried just a cable and Nemo – didn’t work
Tried KConnect, which I wasn’t impressed of.
Ended up installing an FTP server on the phone, and using FileZilla which was an OK solution, but a little clumsy.
So now I read about LocalSend, and decided to give it a try.
I have to say that it worked better than expected.
Installing snap image om my linux, and the APK from google store just worked.
And the transfer speed was better than any other method I have tried.

Posted in linux mint, Uncategorized | Tagged , | Leave a comment

code templates for automatisation

My project is supposed to be used in different countries, so I need to make sure it can be translated.
This requires heavy use of resource strings. you can take a look at the documentation:
https://wiki.freepascal.org/Step-by-step_instructions_for_creating_multi-language_applications
so I declare the string like this: rsTotal = ‘Total’;
Then I will add this to a stringlist, where I can use a “key value pair”
rsStrings.Append(‘rsTotal=’+rsTotal);
This typing is tedious, so I have created a code template:

All need now os set the caption on the label to rsTotal, and copy it to the clipboard.
Now typing rs^j , will do the typing for me.

Using these procedures in the onCreate event will then translate everything on the form for me:

procedure TransCaption(MyForm: TForm; rsStrings: TStringList);
var
  i: integer;
begin
  MyForm.Caption:=chgCap(Myform.Caption,rsStrings);
  for i := 0 to Pred(Myform.ComponentCount) do
  begin
    if MyForm.Components[i] is TLabel then
    (Myform.Components[i] as TLabel).Caption := chgCap((Myform.Components[i] as TLabel).Caption,rsStrings);

    if MyForm.Components[i] is TAction then
       (Myform.Components[i] as TAction).Caption := chgCap((Myform.Components[i] as TAction).Caption,rsStrings);

    if MyForm.Components[i] is TMenuItem then
    (Myform.Components[i] as TMenuItem).Caption := chgCap((Myform.Components[i] as TMenuItem).Caption,rsStrings);

    if MyForm.Components[i] is TButton then
      (Myform.Components[i] as TButton).Caption := chgCap((Myform.Components[i] as TButton).Caption,rsStrings);


    if MyForm.Components[i] is TRadioGroup then
      (Myform.Components[i] as TRadioGroup).Caption := chgCap((Myform.Components[i] as TRadioGroup).Caption,rsStrings);

    if MyForm.Components[i] is TTabsheet then
      (Myform.Components[i] as TTabsheet).Caption := chgCap((Myform.Components[i] as TTabsheet).Caption,rsStrings);

  end;
end;

Function ChgCap(MyCap: TCaption; rsStrings: TStringList):TCaption;
begin
  if Copy(MyCap, 1, 2) = 'rs' then
    MyCap := rsStrings.values[MyCap];
  Result := MyCap;
end;

Posted in Uncategorized | Tagged , , | Leave a comment

PDF issues with imagemagick and lazarus

I ran into my first real Lazarus/FPC issue today. There is no component for displaying or thumbnailing PDF files. I googled it a lot, and it seems there has only been developed something for creating PDFs.
It was to overwhelming creating a component myself, so I decide to take another route: Convert the PDF through a 3 party program, and save the output, where I wanted it.
Decided I would use imagemagick for this. Which gave me the next issue: “attempt to perform an operation not allowed by the security policy `PDF’ @ error/constitute.c/IsCoderAuthorized/421”
This was easier to solve this:
https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion#comment94196251_53180170

Since I am running version 9.55 I was good!
So now I just need to implement the command in my Lazarus project.

Posted in Uncategorized | Tagged , , | Leave a comment

Lazarus procedure list

I do a lot of coding in lazarus and fpc. When I am editing a large file, it can be difficult to navigate to the procedure you want.
By pressing Alt-G,you get a list of procedures, and just click on the one you want.

Posted in linux mint, Uncategorized | Tagged , , | Leave a comment