-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: basic linux version * fix: cleanup * fix: err * feat: deb * fix: ci * fix: maintainer
- Loading branch information
Showing
12 changed files
with
182 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
RAW_VERSION=${RAW_VERSION:-1.0.1} | ||
TARGET_FOLDER=browser-switcher_$RAW_VERSION | ||
|
||
mkdir -p $TARGET_FOLDER/{DEBIAN,usr/local/bin,usr/share/applications} | ||
|
||
cat <<EOF > $TARGET_FOLDER/DEBIAN/control | ||
Package: browser-switcher | ||
Version: $RAW_VERSION | ||
Architecture: all | ||
Maintainer: FT-T <https://github.com/ft-t/browser-switcher> | ||
Description: A tool to switch between browsers. | ||
Priority: optional | ||
Depends: xdg-utils | ||
EOF | ||
|
||
cp ../dist/linux/browser-switcher $TARGET_FOLDER/usr/local/bin/browser-switcher | ||
cp ../dist/linux/browser-switcher-proxied $TARGET_FOLDER/usr/local/bin/browser-switcher-proxied | ||
cp ../dist/linux/browser-switcher.desktop $TARGET_FOLDER/usr/share/applications/browser-switcher.desktop | ||
|
||
cat <<EOF > browser-switcher_$RAW_VERSION/DEBIAN/postinst | ||
#!/bin/bash | ||
set -e | ||
# Create required directories | ||
mkdir -p ~/BrowserSwitcher | ||
xdg-mime default browser-switcher.desktop x-scheme-handler/http | ||
xdg-mime default browser-switcher.desktop x-scheme-handler/https | ||
xdg-settings set default-web-browser browser-switcher.desktop | ||
update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/local/bin/browser-switcher 400 | ||
update-alternatives --set x-www-browser /usr/local/bin/browser-switcher | ||
xdg-settings set default-web-browser browser-switcher.desktop | ||
EOF | ||
|
||
chmod 755 browser-switcher_$RAW_VERSION/DEBIAN/postinst | ||
|
||
dpkg-deb --build $TARGET_FOLDER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//go:build linux | ||
|
||
package launcher | ||
|
||
import ( | ||
"context" | ||
"os/exec" | ||
"slices" | ||
|
||
"github.com/ft-t/browser-switcher/pkg/config" | ||
) | ||
|
||
func (l *Launcher) Launch(ctx context.Context, browser *config.Browser) error { | ||
return exec.Command( | ||
"setsid", | ||
slices.Concat( | ||
[]string{ | ||
browser.BinaryPath, | ||
l.targetURL, | ||
}, | ||
browser.LaunchArgs, | ||
)..., | ||
).Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build windows | ||
|
||
package launcher | ||
|
||
import ( | ||
"context" | ||
"os/exec" | ||
"slices" | ||
|
||
"github.com/ft-t/browser-switcher/pkg/config" | ||
) | ||
|
||
func (l *Launcher) Launch(_ context.Context, browser *config.Browser) error { | ||
return exec.Command( | ||
browser.BinaryPath, | ||
slices.Concat( | ||
[]string{l.targetURL}, | ||
browser.LaunchArgs, | ||
)..., | ||
).Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Desktop Entry] | ||
Version=1.0 | ||
Name=Browser Switcher | ||
Exec=/usr/local/bin/browser-switcher %U | ||
Terminal=false | ||
Type=Application | ||
MimeType=x-scheme-handler/http;x-scheme-handler/https; | ||
Categories=Network;WebBrowser; | ||
StartupNotify=true | ||
MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
sudo mkdir -p /etc/browser-switcher | ||
mkdir -p ~/BrowserSwitcher | ||
|
||
sudo cp -f browser-switcher /usr/local/bin/browser-switcher && sudo chmod 777 /usr/local/bin/browser-switcher | ||
sudo cp -f browser-switcher-proxied /usr/local/bin/browser-switcher-proxied && sudo chmod 777 /usr/local/bin/browser-switcher-proxied | ||
|
||
sudo cp -f browser-switcher.desktop /usr/share/applications/browser-switcher.desktop | ||
sudo xdg-mime default browser-switcher.desktop x-scheme-handler/http | ||
sudo xdg-mime default browser-switcher.desktop x-scheme-handler/https | ||
|
||
sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/local/bin/browser-switcher 400 | ||
sudo update-alternatives --config x-www-browser | ||
|
||
sudo xdg-settings set default-web-browser browser-switcher.desktop |