From 269c6f6e673a88caeb74cb97479baeb9bbd9965c Mon Sep 17 00:00:00 2001 From: JuliaLange Date: Mon, 8 Apr 2024 23:01:37 -0700 Subject: [PATCH] Discord, swap betterdiscord for vesktop Change better discord for vesktop Update hypr rules to call vesktop instead of discord --- programs/discord/default.nix | 9 +- .../discord/plugins/chatlessdisc.plugin.js | 197 ------------------ programs/hypr/window_rules.conf | 2 +- 3 files changed, 2 insertions(+), 206 deletions(-) delete mode 100644 programs/discord/plugins/chatlessdisc.plugin.js diff --git a/programs/discord/default.nix b/programs/discord/default.nix index 4221921..8344f47 100644 --- a/programs/discord/default.nix +++ b/programs/discord/default.nix @@ -1,13 +1,6 @@ { config, pkgs, ... }: -let rootPath = ./.; in { home.packages = with pkgs; [ - discord # Base app - betterdiscordctl # Better Discord Installer + vesktop # Base app ]; - # Better Discord plugins - xdg.configFile."better-discord" = { - source = rootPath + "/plugins"; - target = "BetterDiscord/plugins"; - }; } diff --git a/programs/discord/plugins/chatlessdisc.plugin.js b/programs/discord/plugins/chatlessdisc.plugin.js deleted file mode 100644 index 76d78d2..0000000 --- a/programs/discord/plugins/chatlessdisc.plugin.js +++ /dev/null @@ -1,197 +0,0 @@ -/** - * @name chatlessdisc - * @version 1.1.0 - * @description removes the chatting from disc, as god intended - * @author Julia Lange - * - */ - -const TITLE = "chatless-disc"; - -function getChat() { - let chatsPotentialChild = document.querySelector( - "div > section[aria-label='Channel header']"); - if (chatsPotentialChild) { - let chat = chatsPotentialChild.parentElement; - return chat; - } - return null; -} - -function removeChat() { - let chat = getChat() - if (chat) chat.style = "display: none"; -} -function restoreChat() { - let chat = getChat() - if (chat) chat.style = "display: flex"; -} - -function expandSidebar() { - let userArea = document.querySelector("section[aria-label='User area']"); - let sidebar = userArea.parentElement; - sidebar.style = "width: 100%"; - removeChat(); - - userArea.childNodes.forEach(node => { - node.style = "justify-content: space-between"; - }); -} - -function contractSidebar() { - let userArea = document.querySelector("section[aria-label='User area']"); - let sidebar = userArea.parentElement; - sidebar.style = ""; - restoreChat(); - - userArea.childNodes.forEach(node => { - node.style = ""; - }); -} - -function addChannelClass() { - let dms = document.querySelector("ul[aria-label='Direct Messages']"); - if (dms == null) return ""; - let friendsElement = dms.childNodes[1] - if (friendsElement == null) return ""; - let channelClassName = friendsElement.className.split(" ")[0] - if (channelClassName != "") { - BdApi.DOM.addStyle(TITLE, `.${channelClassName} { - max-width: 100%; - }`); - } - return channelClassName; -} - -function clickPopOut() { - let popOutButton = document.querySelector("button[aria-label='Pop Out']"); - if (popOutButton == null) return; - popOutButton.click(); -} - -function addToggleButton(button) { - let muteButton = document.querySelector("div > button[aria-label='Mute']"); - if (muteButton == null) return; - let buttonList = muteButton.parentElement; - buttonList.prepend(button) - - enablePortraitStyle() -} - -function enablePortraitStyle() { - let portrait = document.querySelector("div[aria-label='Set Status']"); - if (portrait == null) return; - portrait.style = "width: 100%; min-width: 0px"; -} - -function disablePortaitStyle() { - let portrait = document.querySelector("div[aria-label='Set Status']"); - if (portrait == null) return; - portrait.style = ""; -} - -function enableChanges() { - expandSidebar(); - - return true -} - -function disableChanges() { - contractSidebar(); - - return false -} - -function createToggleButton(onClickFunction) { - let toggleButton = document.createElement("button"); - toggleButton.role = "switch"; - toggleButton.ariaLabel = "Chattless Toggle"; - toggleButton.className = "chattless_button"; - toggleButton.style.cssText = ` - display: flex; - align-items: center; - justify-content: center; - background: transparent;` - toggleButton.addEventListener("click", onClickFunction); - - const div = document.createElement("div"); - div.style.cssText = ` - display: flex; - align-items: center; - justify-content: center;`; - - const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); - svg.setAttribute("aria-hidden", "false"); - svg.setAttribute("width", "20"); - svg.setAttribute("height", "20"); - svg.setAttribute("viewBox", "0 0 512.08 512.08"); - - const path = document.createElementNS("http://www.w3.org/2000/svg", "path"); - path.setAttribute("fill", "var(--interactive-normal)"); - path.setAttribute("d", "M256.04,0C134.28,0,35.208,97.248,35.208,216.8c0,66.56,30.208,127.776,83.168,169.216V512.08 \ - l103.552-81.2c11.536,1.776,22.992,2.688,34.112,2.688c121.76,0,220.832-97.232,220.832-216.768C476.872,97.248,377.8,0,256.04,0z \ - M444.872,216.8c0,44.336-16.064,85.056-42.768,116.928L140.408,71.024C172.408,46.656,212.456,32,256.04,32 \ - C360.168,32,444.872,114.912,444.872,216.8z M220.552,398.192l-7.104-1.312l-63.056,49.456v-76.432l-6.592-4.8 \ - C95.128,329.776,67.224,275.712,67.224,216.8c0-47.872,18.848-91.408,49.472-124.256l262.768,263.792 \ - c-33.136,28.096-76.224,45.232-123.408,45.232C244.536,401.568,232.6,400.416,220.552,398.192z"); - - svg.appendChild(path); - div.appendChild(svg); - toggleButton.appendChild(div); - - return toggleButton; -} - - - - - -class chatlessdisc { - - constructor() { - this.enabled = false; - this.channelActionsModule = BdApi.findModuleByProps('selectChannel'); - - this.toggleButton = createToggleButton(async () => { - if (this.enabled) - this.enabled = disableChanges(); - else - this.enabled = enableChanges(); - }); - } - - start() { - this.enabled = enableChanges(); - addToggleButton(this.toggleButton); - this.channelClassName = addChannelClass(); - - BdApi.DOM.addStyle(TITLE, `.chattless_button:hover { - background: rgba(255,255,255,0.125) !important; - }`); - - BdApi.Patcher.instead(TITLE, this.channelActionsModule, - "selectChannel", async (_, args, originalFunction) => { - await originalFunction(...args); - if (this.enabled) { - removeChat(); - if (this.channelClassName == "") - this.channelClassName = addChannelClass(); - } - }); - BdApi.Patcher.instead(TITLE, this.channelActionsModule, - "selectVoiceChannel", async (_, args, originalFunction) => { - await originalFunction(...args); - if (this.enabled) { - await this.channelActionsModule.selectPrivateChannel(args[0]); - clickPopOut(); - } - }); - } - //Turn off and remove all parts of the plugin - stop() { - this.toggleButton.remove() - disableChanges(); - BdApi.Patcher.unpatchAll(TITLE); - BdApi.DOM.removeStyle(TITLE); - } -} diff --git a/programs/hypr/window_rules.conf b/programs/hypr/window_rules.conf index 6643f96..8d084ea 100644 --- a/programs/hypr/window_rules.conf +++ b/programs/hypr/window_rules.conf @@ -35,5 +35,5 @@ windowrulev2 = opacity 1 override, class:^(mpv)$ env = HYPR_WORK_DB,$XDG_CACHE_HOME/hypr/workspace.db exec-once = [workspace special:mus silent;float;size 70% 70%;center] alacritty -e spt -exec-once = [workspace name:chat silent] Discord +exec-once = [workspace name:chat silent] vesktop exec-once = [workspace name:chat silent] beeper