Skip to content

Commit ab7a004

Browse files
committed
add transparency
1 parent 920722e commit ab7a004

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

discocss

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mkdir -p "$confdir"
99
touch "$cssFile"
1010

1111
cat <<EOF > "$preloadFile"
12-
(() => {
12+
module.exports = () => {
1313
const fs = require("fs");
1414
const confDir = "$confdir";
1515
const cssFile = "$cssFile";
@@ -29,7 +29,18 @@ cat <<EOF > "$preloadFile"
2929
}
3030
3131
inject(require("electron").webFrame.context);
32-
})();
32+
};
33+
34+
module.exports.mw = (mainWindow) => {
35+
mainWindow.setBackgroundColor("#00000000");
36+
};
37+
38+
module.exports.mo = (options) => {
39+
options.transparent = true;
40+
if (process.platform === "linux") {
41+
options.frame = true;
42+
}
43+
};
3344
EOF
3445

3546
ln -f -s "$preloadFile" /tmp/discocss-preload.js
@@ -42,7 +53,11 @@ else
4253
core_asar="$(echo "$XDG_CONFIG_HOME/discord/"*"/modules/discord_desktop_core/core.asar")"
4354
fi
4455

45-
LC_ALL=C sed $sed_options 's| // App preload script, used to provide a replacement native API now that|try { require\(`/tmp/discocss-preload.js`) } catch \(e\) {console.error\(e\);} |' \
56+
app_preload_replace='s| // App preload script, used to provide a replacement native API now that|try {require\(`/tmp/discocss-preload.js`)()} catch \(e\) {console.error\(e\);} |'
57+
launch_main_app_replace='s|// launch main app window; could be called multiple times for various reasons| const dp = require(`/tmp/discocss-preload.js`); |'
58+
frame_true_replace='s| mainWindowOptions.frame = true;|}dp.mo(mainWindowOptions);{ |'
59+
causing_the_window_replace='s|// causing the window to be too small on a larger secondary display| dp.mw(mainWindow); |'
60+
LC_ALL=C sed $sed_options "$app_preload_replace; $launch_main_app_replace; $frame_true_replace; $causing_the_window_replace" \
4661
"$core_asar"
4762

4863
command -v discord && exec discord

0 commit comments

Comments
 (0)