Prevent multiple Chromium instances

interpretive language scripts


Moderator: Forum moderators

Post Reply
User avatar
wizard
Posts: 1984
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2648 times
Been thanked: 692 times

Prevent multiple Chromium instances

Post by wizard »

In my current remaster project, Cloudpup-Fossa64, a ChromeOS work-a-like, I want to prevent the user from opening more than one instance of Chromium. No extensions or settings appear to do this. Wrote this script, that works, but think there are probably better ways. Also has a companion script in startup that deletes the test file in case of a ungraceful shutdown.

Feel free to comment and contribute.

wizard

Code: Select all

#! /bin/bash
#prevents multiple Chromium instance

#minimize window
thisid=$(xdotool getactivewindow)
 echo $thisid
xdotool windowminimize $thisid

#check if Chromium is running
FILE=/root/my-applications/bin/chrom-on.txt
if [ -f "$FILE" ]; then
   DIALOG=${DIALOG=Xdialog}
   $DIALOG --title "Chromium" --clear \
        --msgbox "Chromium is already running" 10 30
    exit
fi

#create test file
>/root/my-applications/bin/chrom-on.txt

chromium "$@"
 wait

#remove test file when chromium closes
rm /root/my-applications/bin/chrom-on.txt

Big pile of OLD computers

williwaw
Posts: 1948
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 369 times

Re: Prevent multiple Chromium instances

Post by williwaw »

.

Last edited by williwaw on Mon Dec 27, 2021 10:35 pm, edited 1 time in total.
User avatar
mikewalsh
Moderator
Posts: 6160
Joined: Tue Dec 03, 2019 1:40 pm
Location: King's Lynn, UK
Has thanked: 795 times
Been thanked: 1981 times

Re: Prevent multiple Chromium instances

Post by mikewalsh »

@wizard :-

Maybe something here that could help? These are all command-line/script 'exec' line '--switches' for modifying browser behaviour. I'll warn you; it's a LONG list..!

https://peter.sh/experiments/chromium-c ... -switches/

I've 'skimmed it' on several occasions, but I don't think I've ever read it right from top to bottom.

Mike. ;)

User avatar
wizard
Posts: 1984
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2648 times
Been thanked: 692 times

Re: Prevent multiple Chromium instances

Post by wizard »

@mikewalsh

Thanks mike, I'm using peebee's chromium 94 and did go through the list of experimental switches, no luck, and it is a long list. Couldn't find anything on a web search either.

wizard

Big pile of OLD computers

Post Reply

Return to “Scripts”