From 8cee680be46646eaac09108e7d56f2d82b2a964b Mon Sep 17 00:00:00 2001 From: Sankalp Tharu Date: Thu, 25 May 2023 01:33:52 +0545 Subject: [PATCH] fresh init --- home/.config/bspwm/rofi/bin/askpass | 11 + home/.config/bspwm/rofi/bin/confirm | 8 + home/.config/bspwm/rofi/bin/net | 59 ++ home/.config/bspwm/rofi/bin/nmd | 895 ++++++++++++++++++ home/.config/bspwm/rofi/bin/sxhkd-help | 5 + home/.config/bspwm/rofi/bin/windows | 7 + home/.config/bspwm/rofi/rasi/askpass.rasi | 83 ++ home/.config/bspwm/rofi/rasi/confirm.rasi | 97 ++ .../.config/bspwm/rofi/rasi/emoji/config.rasi | 97 ++ .../bspwm/rofi/rasi/emoji/emojimenu.rasi | 138 +++ home/.config/bspwm/rofi/rasi/launcher.rasi | 127 +++ home/.config/bspwm/rofi/rasi/network.rasi | 168 ++++ home/.config/bspwm/rofi/rasi/networkmenu.rasi | 173 ++++ home/.config/bspwm/rofi/rasi/screenutils.rasi | 128 +++ home/.config/bspwm/rofi/rasi/sxhkd-help.rasi | 131 +++ home/.config/bspwm/rofi/rasi/window.rasi | 178 ++++ 16 files changed, 2305 insertions(+) create mode 100755 home/.config/bspwm/rofi/bin/askpass create mode 100755 home/.config/bspwm/rofi/bin/confirm create mode 100755 home/.config/bspwm/rofi/bin/net create mode 100755 home/.config/bspwm/rofi/bin/nmd create mode 100755 home/.config/bspwm/rofi/bin/sxhkd-help create mode 100755 home/.config/bspwm/rofi/bin/windows create mode 100644 home/.config/bspwm/rofi/rasi/askpass.rasi create mode 100644 home/.config/bspwm/rofi/rasi/confirm.rasi create mode 100644 home/.config/bspwm/rofi/rasi/emoji/config.rasi create mode 100644 home/.config/bspwm/rofi/rasi/emoji/emojimenu.rasi create mode 100755 home/.config/bspwm/rofi/rasi/launcher.rasi create mode 100644 home/.config/bspwm/rofi/rasi/network.rasi create mode 100644 home/.config/bspwm/rofi/rasi/networkmenu.rasi create mode 100644 home/.config/bspwm/rofi/rasi/screenutils.rasi create mode 100644 home/.config/bspwm/rofi/rasi/sxhkd-help.rasi create mode 100644 home/.config/bspwm/rofi/rasi/window.rasi diff --git a/home/.config/bspwm/rofi/bin/askpass b/home/.config/bspwm/rofi/bin/askpass new file mode 100755 index 0000000..e762348 --- /dev/null +++ b/home/.config/bspwm/rofi/bin/askpass @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +## Copyright (C) 2020-2021 Aditya Shakya +## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3 + +rofi -dmenu \ + -password \ + -i \ + -p "Root" \ + -no-fixed-num-lines\ + -theme ~/.config/bspwm/rofi/rasi/askpass.rasi diff --git a/home/.config/bspwm/rofi/bin/confirm b/home/.config/bspwm/rofi/bin/confirm new file mode 100755 index 0000000..e680f40 --- /dev/null +++ b/home/.config/bspwm/rofi/bin/confirm @@ -0,0 +1,8 @@ +#!/bin/bash + +rofi -dmenu \ + -number \ + -i \ + -no-fixed-num-lines\ + -p "Are You Sure? : "\ + -theme $HOME/.config/bspwm/rofi/rasi/confirm.rasi \ No newline at end of file diff --git a/home/.config/bspwm/rofi/bin/net b/home/.config/bspwm/rofi/bin/net new file mode 100755 index 0000000..01f3c42 --- /dev/null +++ b/home/.config/bspwm/rofi/bin/net @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +rofi_command="rofi -theme $HOME/.config/bspwm/rofi/rasi/network.rasi" + +## Get info +IFACE="$(nmcli | grep -i interface | head -n1 | cut -d' ' -f2)" +STATUS="$(nmcli radio wifi)" +_SSID="$(iwgetid -r)" +_LIP="$(nmcli | grep -i server | head -n1 | cut -d' ' -f2)" +_PIP="$(wget --timeout=30 http://ipinfo.io/ip -qO -)" + +active="" +urgent="" + +if (ping -c 1 archlinux.org || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) &>/dev/null; then + if [[ $STATUS == *"enable"* ]]; then + if [[ $IFACE == e* ]]; then + connected="直 Connected To Internet" + else + connected="直 Connected To Internet" + fi + active="-a 0" + SSID="$_SSID" + PIP="$_PIP" + fi +else + urgent="-u 0" + SSID="Disconnected" + PIP="NA" + connected="睊 Offline" +fi + +## Icons +bmon=" Open Bandwidth Monitor" +launch_cli=" Open Network Manager" +launch="ﯱ Open Connection Editor" + +options="$connected\n$bmon\n$launch_cli\n$launch" + +## Main +chosen="$(echo -e "$options" | $rofi_command -p "$SSID : $PIP" -dmenu $active $urgent -selected-row 1)" +case $chosen in + $connected) + if [[ $STATUS == *"enable"* ]]; then + nmcli radio wifi off + else + nmcli radio wifi on + fi + ;; + $bmon) + alacritty -e bmon + ;; + $launch_cli) + alacritty -e nmtui + ;; + $launch) + nm-connection-editor + ;; +esac + diff --git a/home/.config/bspwm/rofi/bin/nmd b/home/.config/bspwm/rofi/bin/nmd new file mode 100755 index 0000000..6926f2c --- /dev/null +++ b/home/.config/bspwm/rofi/bin/nmd @@ -0,0 +1,895 @@ +#!/usr/bin/env python3 +# encoding:utf8 +"""NetworkManager command line dmenu script. + +To add new connections or enable/disable networking requires policykit +permissions setup per: +https://wiki.archlinux.org/index.php/NetworkManager#Set_up_PolicyKit_permissions + +OR running the script as root + +Add dmenu options and default terminal if desired to +~/.config/networkmanager-dmenu/nmd.ini + +""" +import pathlib +import struct +import configparser +import locale +import os +from os.path import expanduser +import shlex +from shutil import which +import sys +import uuid +import subprocess + +import gi +gi.require_version('NM', '1.0') +from gi.repository import GLib, NM # noqa pylint: disable=wrong-import-position + +ENV = os.environ.copy() +ENV['LC_ALL'] = 'C' +ENC = locale.getpreferredencoding() + +CLIENT = NM.Client.new(None) +LOOP = GLib.MainLoop() +CONNS = CLIENT.get_connections() + +CONF = configparser.ConfigParser() +CONF.read(expanduser("~/.config/networkmanager-dmenu/nmd.ini")) + + +def cli_args(): + """ Don't override dmenu_cmd function arguments with CLI args. Removes -l + and -p if those are passed on the command line. + + Exception: if -l is passed and dmenu_command is not defined, assume that the + user wants to switch dmenu to the vertical layout and include -l. + + Returns: List of additional CLI arguments + + """ + args = sys.argv[1:] + cmd = CONF.get('dmenu', 'dmenu_command', fallback=False) + if "-l" in args or "-p" in args: + for nope in ['-l', '-p'] if cmd is not False else ['-p']: + try: + nope_idx = args.index(nope) + del args[nope_idx] + del args[nope_idx] + except ValueError: + pass + return args + + +def dmenu_pass(command, color): + """Check if dmenu passphrase patch is applied and return the correct command + line arg list + + Args: command - string + color - obscure color string + Returns: list or None + + """ + if command != 'dmenu': + return None + try: + # Check for dmenu password patch + dm_patch = b'P' in subprocess.run(["dmenu", "-h"], + capture_output=True, + check=False).stderr + except FileNotFoundError: + dm_patch = False + return ["-P"] if dm_patch else ["-nb", color, "-nf", color] + + +def dmenu_cmd(num_lines, prompt="Networks", active_lines=None): + """Parse nmd.ini for menu options + + Args: args - num_lines: number of lines to display + prompt: prompt to show + active_lines: list of line numbers to tag as active + Returns: command invocation (as a list of strings) for example + ["dmenu", "-l", "", "-p", "", "-i"] + + """ + # Create command string + commands = {"dmenu": ["-p", str(prompt)], + "rofi": ["-dmenu", "-p", str(prompt), "-l", str(num_lines)], + "bemenu": ["-p", str(prompt)], + "wofi": ["-p", str(prompt)]} + command = shlex.split(CONF.get('dmenu', 'dmenu_command', fallback="dmenu")) + command.extend(cli_args()) + command.extend(commands.get(command[0], [])) + # Rofi Highlighting + rofi_highlight = CONF.getboolean('dmenu', 'rofi_highlight', fallback=False) + if rofi_highlight is True and command[0] == "rofi" and active_lines: + command.extend(["-a", ",".join([str(num) for num in active_lines])]) + # Passphrase prompts + obscure = CONF.getboolean('dmenu_passphrase', 'obscure', fallback=False) + if prompt == "Passphrase" and obscure is True: + obscure_color = CONF.get('dmenu_passphrase', 'obscure_color', fallback='#222222') + pass_prompts = {"dmenu": dmenu_pass(command[0], obscure_color), + "rofi": ['-password'], + "bemenu": ['-x'], + "wofi": ['-P']} + command.extend(pass_prompts.get(command[0], [])) + return command + + +def choose_adapter(client): + """If there is more than one wifi adapter installed, ask which one to use + + """ + devices = client.get_devices() + devices = [i for i in devices if i.get_device_type() == NM.DeviceType.WIFI] + if not devices: + return None + if len(devices) == 1: + return devices[0] + device_names = "\n".join([d.get_iface() for d in devices]) + sel = subprocess.run(dmenu_cmd(len(devices), "CHOOSE ADAPTER:"), + capture_output=True, + check=False, + env=ENV, + input=device_names, + encoding=ENC).stdout + if not sel.strip(): + sys.exit() + devices = [i for i in devices if i.get_iface() == sel.strip()] + assert len(devices) == 1 + return devices[0] + + +def is_installed(cmd): + """Check if a utility is installed""" + return which(cmd) is not None + + +def bluetooth_get_enabled(): + """Check if bluetooth is enabled via rfkill. + + Returns None if no bluetooth device was found. + """ + # See https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-class-rfkill + for path in pathlib.Path('/sys/class/rfkill/').glob('rfkill*'): + if (path / 'type').read_text().strip() == 'bluetooth': + return (path / 'soft').read_text().strip() == '0' + return None + + +def create_other_actions(client): + """Return list of other actions that can be taken + + """ + networking_enabled = client.networking_get_enabled() + networking_action = "Disable" if networking_enabled else "Enable" + + wifi_enabled = client.wireless_get_enabled() + wifi_action = "Disable" if wifi_enabled else "Enable" + + bluetooth_enabled = bluetooth_get_enabled() + bluetooth_action = "Disable" if bluetooth_enabled else "Enable" + + actions = [Action(f"{wifi_action} Wifi", toggle_wifi, + not wifi_enabled), + Action(f"{networking_action} Networking", + toggle_networking, not networking_enabled)] + if bluetooth_enabled is not None: + actions.append(Action(f"{bluetooth_action} Bluetooth", + toggle_bluetooth, not bluetooth_enabled)) + actions += [Action("Launch Connection Manager", launch_connection_editor), + Action("Delete a Connection", delete_connection)] + if wifi_enabled: + actions.append(Action("Rescan Wifi Networks", rescan_wifi)) + return actions + + +def rescan_wifi(): + """ + Rescan Wifi Access Points + """ + for dev in CLIENT.get_devices(): + if gi.repository.NM.DeviceWifi == type(dev): + try: + dev.request_scan_async(None, rescan_cb, None) + LOOP.run() + except gi.repository.GLib.Error as err: + # Too frequent rescan error + notify("Wifi rescan failed", urgency="critical") + if not err.code == 6: # pylint: disable=no-member + raise err + + +def rescan_cb(dev, res, data): + """Callback for rescan_wifi. Just for notifications + + """ + if dev.request_scan_finish(res) is True: + notify("Wifi scan complete") + else: + notify("Wifi scan failed", urgency="critical") + LOOP.quit() + + +def ssid_to_utf8(nm_ap): + """ Convert binary ssid to utf-8 """ + ssid = nm_ap.get_ssid() + if not ssid: + return "" + ret = NM.utils_ssid_to_utf8(ssid.get_data()) + return ret + + +def prompt_saved(saved_cons): + """Prompt for a saved connection.""" + actions = create_saved_actions(saved_cons) + sel = get_selection(actions) + sel() + + +def ap_security(nm_ap): + """Parse the security flags to return a string with 'WPA2', etc. """ + flags = nm_ap.get_flags() + wpa_flags = nm_ap.get_wpa_flags() + rsn_flags = nm_ap.get_rsn_flags() + sec_str = "" + if ((flags & getattr(NM, '80211ApFlags').PRIVACY) and + (wpa_flags == 0) and (rsn_flags == 0)): + sec_str += " WEP" + if wpa_flags != 0: + sec_str += " WPA1" + if rsn_flags != 0: + sec_str += " WPA2" + if ((wpa_flags & getattr(NM, '80211ApSecurityFlags').KEY_MGMT_802_1X) or + (rsn_flags & getattr(NM, '80211ApSecurityFlags').KEY_MGMT_802_1X)): + sec_str += " 802.1X" + + # If there is no security use "--" + if sec_str == "": + sec_str = "--" + return sec_str.lstrip() + + +class Action(): # pylint: disable=too-few-public-methods + """Helper class to execute functions from a string variable""" + def __init__(self, + name, + func, + args=None, + active=False): + self.name = name + self.func = func + self.is_active = active + if args is None: + self.args = None + elif isinstance(args, list): + self.args = args + else: + self.args = [args] + + def __str__(self): + return self.name + + def __call__(self): + if self.args is None: + self.func() + else: + self.func(*self.args) + + +def conn_matches_adapter(conn, adapter): + """Return True if the connection is applicable for the given adapter. + + There seem to be two ways for a connection specify what interface it belongs + to: + + - By setting 'mac-address' in [wifi] to the adapter's MAC + - By setting 'interface-name` in [connection] to the adapter's name. + + Depending on how the connection was added, it seems like either + 'mac-address', 'interface-name' or neither of both is set. + """ + # [wifi] mac-address + setting_wireless = conn.get_setting_wireless() + mac = setting_wireless.get_mac_address() + if mac is not None: + return mac == adapter.get_permanent_hw_address() + + # [connection] interface-name + setting_connection = conn.get_setting_connection() + interface = setting_connection.get_interface_name() + if interface is not None: + return interface == adapter.get_iface() + + # Neither is set, let's assume this connection is for multiple/all adapters. + return True + + +def process_ap(nm_ap, is_active, adapter): + """Activate/Deactivate a connection and get password if required""" + if is_active: + CLIENT.deactivate_connection_async(nm_ap, None, deactivate_cb, nm_ap) + LOOP.run() + else: + conns_cur = [i for i in CONNS if + i.get_setting_wireless() is not None and + conn_matches_adapter(i, adapter)] + con = nm_ap.filter_connections(conns_cur) + if len(con) > 1: + raise ValueError("There are multiple connections possible") + + if len(con) == 1: + CLIENT.activate_connection_async(con[0], adapter, nm_ap.get_path(), + None, activate_cb, nm_ap) + LOOP.run() + else: + if ap_security(nm_ap) != "--": + password = get_passphrase() + else: + password = "" + set_new_connection(nm_ap, password, adapter) + + +def activate_cb(dev, res, data): + """Notification if activate connection completed successfully + + """ + try: + conn = dev.activate_connection_finish(res) + except GLib.Error: + conn = None + if conn is not None: + notify(f"Activated {conn.get_id()}") + else: + notify(f"Problem activating {data.get_id()}", urgency="critical") + LOOP.quit() + + +def deactivate_cb(dev, res, data): + """Notification if deactivate connection completed successfully + + """ + if dev.deactivate_connection_finish(res) is True: + notify(f"Deactivated {data.get_id()}") + else: + notify(f"Problem deactivating {data.get_id()}", urgency="critical") + LOOP.quit() + + +def process_vpngsm(con, activate): + """Activate/deactive VPN or GSM connections""" + if activate: + CLIENT.activate_connection_async(con, None, None, + None, activate_cb, con) + else: + CLIENT.deactivate_connection_async(con, None, deactivate_cb, con) + LOOP.run() + + +def create_ap_actions(aps, active_ap, active_connection, adapter): # noqa pylint: disable=too-many-locals,line-too-long + """For each AP in a list, create the string and its attached function + (activate/deactivate) + + """ + active_ap_bssid = active_ap.get_bssid() if active_ap is not None else "" + + names = [ssid_to_utf8(ap) for ap in aps] + max_len_name = max([len(name) for name in names]) if names else 0 + secs = [ap_security(ap) for ap in aps] + max_len_sec = max([len(sec) for sec in secs]) if secs else 0 + + ap_actions = [] + + for nm_ap, name, sec in zip(aps, names, secs): + bars = NM.utils_wifi_strength_bars(nm_ap.get_strength()) + wifi_chars = CONF.get("dmenu", "wifi_chars", fallback=False) + if wifi_chars: + bars = "".join([wifi_chars[i] for i, j in enumerate(bars) if j == '*']) + is_active = nm_ap.get_bssid() == active_ap_bssid + compact = CONF.getboolean("dmenu", "compact", fallback=False) + if compact: + action_name = f"{name} {sec} {bars}" + else: + action_name = f"{name:<{max_len_name}s} {sec:<{max_len_sec}s} {bars:>4}" + if is_active: + ap_actions.append(Action(action_name, process_ap, + [active_connection, True, adapter], + active=True)) + else: + ap_actions.append(Action(action_name, process_ap, + [nm_ap, False, adapter])) + return ap_actions + + +def create_vpn_actions(vpns, active): + """Create the list of strings to display with associated function + (activate/deactivate) for VPN connections. + + """ + active_vpns = [i for i in active if i.get_vpn()] + return _create_vpngsm_actions(vpns, active_vpns, "VPN") + + +def create_wireguard_actions(wgs, active): + """Create the list of strings to display with associated function + (activate/deactivate) for Wireguard connections. + + """ + active_wgs = [i for i in active if i.get_connection_type() == "wireguard"] + return _create_vpngsm_actions(wgs, active_wgs, "Wireguard") + + +def create_eth_actions(eths, active): + """Create the list of strings to display with associated function + (activate/deactivate) for Ethernet connections. + + """ + active_eths = [i for i in active if 'ethernet' in i.get_connection_type()] + return _create_vpngsm_actions(eths, active_eths, "Eth") + + +def create_gsm_actions(gsms, active): + """Create the list of strings to display with associated function + (activate/deactivate) GSM connections.""" + active_gsms = [i for i in active if + i.get_connection() is not None and + i.get_connection().is_type(NM.SETTING_GSM_SETTING_NAME)] + return _create_vpngsm_actions(gsms, active_gsms, "GSM") + + +def create_blue_actions(blues, active): + """Create the list of strings to display with associated function + (activate/deactivate) Bluetooth connections.""" + active_blues = [i for i in active if + i.get_connection() is not None and + i.get_connection().is_type(NM.SETTING_BLUETOOTH_SETTING_NAME)] + return _create_vpngsm_actions(blues, active_blues, "Bluetooth") + + +def create_saved_actions(saved): + """Create the list of strings to display with associated function + (activate/deactivate) for VPN connections. + + """ + return _create_vpngsm_actions(saved, [], "SAVED") + + +def _create_vpngsm_actions(cons, active_cons, label): + active_con_ids = [a.get_id() for a in active_cons] + actions = [] + for con in cons: + is_active = con.get_id() in active_con_ids + action_name = f"{con.get_id()}:{label}" + if is_active: + active_connection = [a for a in active_cons + if a.get_id() == con.get_id()] + if len(active_connection) != 1: + raise ValueError(f"Multiple active connections match {con.get_id()}") + active_connection = active_connection[0] + + actions.append(Action(action_name, process_vpngsm, + [active_connection, False], active=True)) + else: + actions.append(Action(action_name, process_vpngsm, + [con, True])) + return actions + + +def create_wwan_actions(client): + """Create WWWAN actions + + """ + wwan_enabled = client.wwan_get_enabled() + wwan_action = "Disable" if wwan_enabled else "Enable" + return [Action(f"{wwan_action} WWAN", toggle_wwan, not wwan_enabled)] + + +def combine_actions(eths, aps, vpns, wgs, gsms, blues, wwan, others, saved): + # pylint: disable=too-many-arguments + """Combine all given actions into a list of actions. + + Args: args - eths: list of Actions + aps: list of Actions + vpns: list of Actions + gsms: list of Actions + blues: list of Actions + wwan: list of Actions + others: list of Actions + """ + compact = CONF.getboolean("dmenu", "compact", fallback=False) + empty_action = [Action('', None)] if not compact else [] + all_actions = [] + all_actions += eths + empty_action if eths else [] + all_actions += aps + empty_action if aps else [] + all_actions += vpns + empty_action if vpns else [] + all_actions += wgs + empty_action if wgs else [] + all_actions += gsms + empty_action if (gsms and wwan) else [] + all_actions += blues + empty_action if blues else [] + all_actions += wwan + empty_action if wwan else [] + all_actions += others + empty_action if others else [] + all_actions += saved + empty_action if saved else [] + return all_actions + + +def get_selection(all_actions): + """Spawn dmenu for selection and execute the associated action.""" + rofi_highlight = CONF.getboolean('dmenu', 'rofi_highlight', fallback=False) + inp = [] + + if rofi_highlight is True: + inp = [str(action) for action in all_actions] + else: + inp = [('== ' if action.is_active else ' ') + str(action) + for action in all_actions] + active_lines = [index for index, action in enumerate(all_actions) + if action.is_active] + + command = dmenu_cmd(len(inp), active_lines=active_lines) + sel = subprocess.run(command, + capture_output=True, + check=False, + input="\n".join(inp), + encoding=ENC, + env=ENV).stdout + + if not sel.rstrip(): + sys.exit() + + if rofi_highlight is False: + action = [i for i in all_actions + if ((str(i).strip() == str(sel.strip()) + and not i.is_active) or + ('== ' + str(i) == str(sel.rstrip('\n')) + and i.is_active))] + else: + action = [i for i in all_actions if str(i).strip() == sel.strip()] + assert len(action) == 1, f"Selection was ambiguous: '{str(sel.strip())}'" + return action[0] + + +def toggle_networking(enable): + """Enable/disable networking + + Args: enable - boolean + + """ + toggle = GLib.Variant.new_tuple(GLib.Variant.new_boolean(enable)) + try: + CLIENT.dbus_call(NM.DBUS_PATH, NM.DBUS_INTERFACE, "Enable", toggle, + None, -1, None, None, None) + except AttributeError: + # Workaround for older versions of python-gobject + CLIENT.networking_set_enabled(enable) + notify(f"Networking {'enabled' if enable is True else 'disabled'}") + + +def toggle_wifi(enable): + """Enable/disable Wifi + + Args: enable - boolean + + """ + toggle = GLib.Variant.new_boolean(enable) + try: + CLIENT.dbus_set_property(NM.DBUS_PATH, NM.DBUS_INTERFACE, "WirelessEnabled", toggle, + -1, None, None, None) + except AttributeError: + # Workaround for older versions of python-gobject + CLIENT.wireless_set_enabled(enable) + notify(f"Wifi {'enabled' if enable is True else 'disabled'}") + + +def toggle_wwan(enable): + """Enable/disable WWAN + + Args: enable - boolean + + """ + toggle = GLib.Variant.new_boolean(enable) + try: + CLIENT.dbus_set_property(NM.DBUS_PATH, NM.DBUS_INTERFACE, "WwanEnabled", toggle, + -1, None, None, None) + except AttributeError: + # Workaround for older versions of python-gobject + CLIENT.wwan_set_enabled(enable) + notify(f"Wwan {'enabled' if enable is True else 'disabled'}") + + +def toggle_bluetooth(enable): + """Enable/disable Bluetooth + + Args: enable - boolean + + References: + https://github.com/blueman-project/blueman/blob/master/blueman/plugins/mechanism/RfKill.py + https://www.kernel.org/doc/html/latest/driver-api/rfkill.html + https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/uapi/linux/rfkill.h?h=v5.8.9 + + """ + type_bluetooth = 2 + op_change_all = 3 + idx = 0 + soft_state = 0 if enable else 1 + hard_state = 0 + + data = struct.pack("IBBBB", idx, type_bluetooth, op_change_all, + soft_state, hard_state) + + try: + with open('/dev/rfkill', 'r+b', buffering=0) as rff: + rff.write(data) + except PermissionError: + notify("Lacking permission to write to /dev/rfkill.", + "Check README for configuration options.", + urgency="critical") + else: + notify(f"Bluetooth {'enabled' if enable else 'disabled'}") + + +def launch_connection_editor(): + """Launch nmtui or the gui nm-connection-editor + + """ + terminal = CONF.get("editor", "terminal", fallback="xterm") + gui_if_available = CONF.getboolean("editor", "gui_if_available", fallback=True) + guis = ["gnome-continue-center", "nm-connection-editor"] + if gui_if_available is True: + for gui in guis: + if is_installed(gui): + subprocess.run(gui, check=False) + return + if is_installed("nmtui"): + subprocess.run([terminal, "-e", "nmtui"], check=False) + return + notify("No network connection editor installed", urgency="critical") + + +def get_passphrase(): + """Get a password + + Returns: string + + """ + pinentry = CONF.get("dmenu", "pinentry", fallback=None) + if pinentry: + pin = "" + out = subprocess.run(pinentry, + capture_output=True, + check=False, + encoding=ENC, + input='setdesc Get network password\ngetpin\n').stdout + if out: + res = out.split("\n")[2] + if res.startswith("D "): + pin = res.split("D ")[1] + return pin + return subprocess.run(dmenu_cmd(0, "Passphrase"), + stdin=subprocess.DEVNULL, + capture_output=True, + check=False, + encoding=ENC).stdout + + +def delete_connection(): + """Display list of NM connections and delete the selected one + + """ + conn_acts = [Action(i.get_id(), i.delete_async, args=[None, delete_cb, None]) for i in CONNS] + conn_names = "\n".join([str(i) for i in conn_acts]) + sel = subprocess.run(dmenu_cmd(len(conn_acts), "CHOOSE CONNECTION TO DELETE:"), + capture_output=True, + check=False, + input=conn_names, + encoding=ENC, + env=ENV).stdout + if not sel.strip(): + sys.exit() + action = [i for i in conn_acts if str(i) == sel.rstrip("\n")] + assert len(action) == 1, f"Selection was ambiguous: {str(sel)}" + action[0]() + LOOP.run() + + +def delete_cb(dev, res, data): + """Notification if delete completed successfully + + """ + if dev.delete_finish(res) is True: + notify(f"Deleted {dev.get_id()}") + else: + notify(f"Problem deleting {dev.get_id()}", urgency="critical") + LOOP.quit() + + +def set_new_connection(nm_ap, nm_pw, adapter): + """Setup a new NetworkManager connection + + Args: ap - NM.AccessPoint + pw - string + + """ + nm_pw = str(nm_pw).strip() + profile = create_wifi_profile(nm_ap, nm_pw, adapter) + CLIENT.add_and_activate_connection_async(profile, adapter, nm_ap.get_path(), + None, verify_conn, profile) + LOOP.run() + + +def create_wifi_profile(nm_ap, password, adapter): + # pylint: disable=line-too-long + # From https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python/gi/add_connection.py + # and https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python/dbus/add-wifi-psk-connection.py + # pylint: enable=line-too-long + """Create the NM profile given the AP and passphrase""" + ap_sec = ap_security(nm_ap) + profile = NM.SimpleConnection.new() + + s_con = NM.SettingConnection.new() + s_con.set_property(NM.SETTING_CONNECTION_ID, ssid_to_utf8(nm_ap)) + s_con.set_property(NM.SETTING_CONNECTION_UUID, str(uuid.uuid4())) + s_con.set_property(NM.SETTING_CONNECTION_TYPE, "802-11-wireless") + profile.add_setting(s_con) + + s_wifi = NM.SettingWireless.new() + s_wifi.set_property(NM.SETTING_WIRELESS_SSID, nm_ap.get_ssid()) + s_wifi.set_property(NM.SETTING_WIRELESS_MODE, 'infrastructure') + s_wifi.set_property(NM.SETTING_WIRELESS_MAC_ADDRESS, adapter.get_permanent_hw_address()) + profile.add_setting(s_wifi) + + s_ip4 = NM.SettingIP4Config.new() + s_ip4.set_property(NM.SETTING_IP_CONFIG_METHOD, "auto") + profile.add_setting(s_ip4) + + s_ip6 = NM.SettingIP6Config.new() + s_ip6.set_property(NM.SETTING_IP_CONFIG_METHOD, "auto") + profile.add_setting(s_ip6) + + if ap_sec != "--": + s_wifi_sec = NM.SettingWirelessSecurity.new() + if "WPA" in ap_sec: + s_wifi_sec.set_property(NM.SETTING_WIRELESS_SECURITY_KEY_MGMT, + "wpa-psk") + s_wifi_sec.set_property(NM.SETTING_WIRELESS_SECURITY_AUTH_ALG, + "open") + s_wifi_sec.set_property(NM.SETTING_WIRELESS_SECURITY_PSK, password) + elif "WEP" in ap_sec: + s_wifi_sec.set_property(NM.SETTING_WIRELESS_SECURITY_KEY_MGMT, + "None") + s_wifi_sec.set_property(NM.SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, + NM.WepKeyType.PASSPHRASE) + s_wifi_sec.set_wep_key(0, password) + profile.add_setting(s_wifi_sec) + + return profile + + +def verify_conn(client, result, data): + """Callback function for add_and_activate_connection_async + + Check if connection completes successfully. Delete the connection if there + is an error. + + """ + try: + act_conn = client.add_and_activate_connection_finish(result) + conn = act_conn.get_connection() + if not all([conn.verify(), + conn.verify_secrets(), + data.verify(), + data.verify_secrets()]): + raise GLib.Error + notify(f"Added {conn.get_id()}") + except GLib.Error: + try: + notify(f"Connection to {conn.get_id()} failed", + urgency="critical") + conn.delete_async(None, None, None) + except UnboundLocalError: + pass + finally: + LOOP.quit() + + +def create_ap_list(adapter, active_connections): + """Generate list of access points. Remove duplicate APs , keeping strongest + ones and the active AP + + Args: adapter + active_connections - list of all active connections + Returns: aps - list of access points + active_ap - active AP + active_ap_con - active Connection + adapter + + """ + aps = [] + ap_names = [] + active_ap = adapter.get_active_access_point() + aps_all = sorted(adapter.get_access_points(), + key=lambda a: a.get_strength(), reverse=True) + conns_cur = [i for i in CONNS if + i.get_setting_wireless() is not None and + conn_matches_adapter(i, adapter)] + try: + ap_conns = active_ap.filter_connections(conns_cur) + active_ap_name = ssid_to_utf8(active_ap) + active_ap_con = [active_conn for active_conn in active_connections + if active_conn.get_connection() in ap_conns] + except AttributeError: + active_ap_name = None + active_ap_con = [] + if len(active_ap_con) > 1: + raise ValueError("Multiple connection profiles match" + " the wireless AP") + active_ap_con = active_ap_con[0] if active_ap_con else None + for nm_ap in aps_all: + ap_name = ssid_to_utf8(nm_ap) + if nm_ap != active_ap and ap_name == active_ap_name: + # Skip adding AP if it's not active but same name as active AP + continue + if ap_name not in ap_names: + ap_names.append(ap_name) + aps.append(nm_ap) + return aps, active_ap, active_ap_con, adapter + + +def notify(message, details=None, urgency="low"): + args = ["-u", urgency, "-a", "Network", "-i", "~/.config/bspwm/assets/icons/network.svg", message] + if details is not None: + args.append(details) + if is_installed("notify-send"): + subprocess.run(["notify-send"] + args, check=False) + + +def run(): # pylint: disable=too-many-locals + """Main script entrypoint""" + active = CLIENT.get_active_connections() + adapter = choose_adapter(CLIENT) + if adapter: + ap_actions = create_ap_actions(*create_ap_list(adapter, active)) + else: + ap_actions = [] + + vpns = [i for i in CONNS if i.is_type(NM.SETTING_VPN_SETTING_NAME)] + try: + wgs = [i for i in CONNS if i.is_type(NM.SETTING_WIREGUARD_SETTING_NAME)] + except AttributeError: + # Workaround for older versions of python-gobject with no wireguard support + wgs = [] + eths = [i for i in CONNS if i.is_type(NM.SETTING_WIRED_SETTING_NAME)] + blues = [i for i in CONNS if i.is_type(NM.SETTING_BLUETOOTH_SETTING_NAME)] + + vpn_actions = create_vpn_actions(vpns, active) + wg_actions = create_wireguard_actions(wgs, active) + eth_actions = create_eth_actions(eths, active) + blue_actions = create_blue_actions(blues, active) + other_actions = create_other_actions(CLIENT) + wwan_installed = is_installed("ModemManager") + if wwan_installed: + gsms = [i for i in CONNS if i.is_type(NM.SETTING_GSM_SETTING_NAME)] + gsm_actions = create_gsm_actions(gsms, active) + wwan_actions = create_wwan_actions(CLIENT) + else: + gsm_actions = [] + wwan_actions = [] + + list_saved = CONF.getboolean('dmenu', 'list_saved', fallback=False) + saved_cons = [i for i in CONNS if i not in vpns + wgs + eths + blues] + if list_saved: + saved_actions = create_saved_actions(saved_cons) + else: + saved_actions = [Action("Saved connections", prompt_saved, [saved_cons])] + + actions = combine_actions(eth_actions, ap_actions, vpn_actions, wg_actions, + gsm_actions, blue_actions, wwan_actions, + other_actions, saved_actions) + sel = get_selection(actions) + sel() + + +if __name__ == '__main__': + run() + +# vim: set et ts=4 sw=4 : diff --git a/home/.config/bspwm/rofi/bin/sxhkd-help b/home/.config/bspwm/rofi/bin/sxhkd-help new file mode 100755 index 0000000..2fcec28 --- /dev/null +++ b/home/.config/bspwm/rofi/bin/sxhkd-help @@ -0,0 +1,5 @@ +#!/bin/bash + +awk '/^[a-z]/ && last {print "",$0,"\t",last,""} {last=""} /^#/{last=$0}' ~/.config/bspwm/sxhkdrc{,.common} | + column -t -s $'\t' | + rofi -dmenu -i -markup-rows -no-show-icons -theme ~/.config/bspwm/rofi/rasi/sxhkd-help.rasi \ No newline at end of file diff --git a/home/.config/bspwm/rofi/bin/windows b/home/.config/bspwm/rofi/bin/windows new file mode 100755 index 0000000..f942d19 --- /dev/null +++ b/home/.config/bspwm/rofi/bin/windows @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + + + +DIR="$HOME/.config/bspwm/rofi" + +rofi -no-lazy-grab -show window -theme $DIR/rasi/window.rasi diff --git a/home/.config/bspwm/rofi/rasi/askpass.rasi b/home/.config/bspwm/rofi/rasi/askpass.rasi new file mode 100644 index 0000000..cd068cb --- /dev/null +++ b/home/.config/bspwm/rofi/rasi/askpass.rasi @@ -0,0 +1,83 @@ +/** + * Copyright (C) 2020-2022 Aditya Shakya + **/ + +/*****----- Global Properties -----*****/ +* { + font: "Iosevka 10"; + background: #222d32; + background-alt: #2c3a41; + foreground: #c4c7c5; + selected: #00BCD4; + active: #61c766; + urgent: #ec7875; +} + + +/*****----- Main Window -----*****/ +window { + location: center; + anchor: center; + fullscreen: false; + width: 350px; + x-offset: 0px; + y-offset: 0px; + padding: 15px; + border: 0px solid; + border-radius: 0px; + border-color: @selected; + background-color: @background; + cursor: "default"; + children: [ "inputbar", "listview" ]; +} + +/*****----- Inputbar -----*****/ +inputbar { + enabled: true; + spacing: 10px; + margin: 0px; + padding: 0px; + border: 0px solid; + border-radius: 0px; + border-color: @selected; + background-color: transparent; + text-color: @foreground; + children: [ "textbox-prompt-colon", "prompt", "entry" ]; +} + +dummy { + expand: false; + width: 10px; + background-color: transparent; +} +textbox-prompt-colon { + enabled: true; + expand: false; + str: ""; + padding: 10px 13px; + border-radius: 0px; + background-color: @urgent; + text-color: @background; +} +prompt { + enabled: true; + padding: 10px; + border-radius: 0px; + background-color: @selected; + text-color: @background; +} +entry { + enabled: true; + padding: 10px 15px; + border-radius: 0px; + background-color: @background-alt; + text-color: inherit; + cursor: text; + placeholder: "Password"; + placeholder-color: inherit; +} + +/*****----- Listview -----*****/ +listview { + enabled: false; +} diff --git a/home/.config/bspwm/rofi/rasi/confirm.rasi b/home/.config/bspwm/rofi/rasi/confirm.rasi new file mode 100644 index 0000000..05e006e --- /dev/null +++ b/home/.config/bspwm/rofi/rasi/confirm.rasi @@ -0,0 +1,97 @@ + +* { + background-color: @background; + text-color: @foreground; + font: "JetBrains Mono Medium 10"; +background: #1A1B26; +foreground: #D4BFFF; +darker: #161A1E; +lighter: #22262A; +pink: #FFDEDE; +red: #E5A3A1; +green: #B4E3AD; +blue: #A3CBE7; +selected: #73A3DE; +background-alt: #D06FE8; +urgent: #E66D76; +active: #5EDEA3; +off: #E66D76; + BG: #1E1D2Fff; + BGA: #89DCEBff; + FG: #D9E0EEff; + FGA: #F28FADff; + BDR: #96CDFBff; + SEL: #1E1E2Eff; + UGT: #F28FADff; + IMG: #FAE3B0ff; + OFF: #575268ff; + ON: #ABE9B3ff; +} + +/*****----- Main Window -----*****/ +window { + location: center; + anchor: center; + fullscreen: false; + width: 320px; + x-offset: 0px; + y-offset: 0px; + padding: 15px; + border: 0px solid; + border-radius: 0px; + border-color: @selected; + background-color: @background; + cursor: "default"; + children: [ "inputbar", "listview" ]; +} + +/*****----- Inputbar -----*****/ +inputbar { + enabled: true; + spacing: 10px; + margin: 0px; + padding: 0px; + border: 0px solid; + border-radius: 0px; + border-color: @selected; + background-color: transparent; + text-color: @foreground; + children: [ "textbox-prompt-colon", "prompt", "entry" ]; +} + +dummy { + expand: false; + width: 10px; + background-color: transparent; +} +textbox-prompt-colon { + enabled: true; + expand: false; + str: ""; + padding: 10px 13px; + border-radius: 0px; + background-color: @urgent; + text-color: @background; +} +prompt { + enabled: true; + padding: 10px; + border-radius: 0px; + background-color: @selected; + text-color: @background; +} +entry { + enabled: true; + padding: 10px 15px; + border-radius: 0px; + background-color: @background-alt; + text-color: inherit; + cursor: text; + placeholder: "Confirm"; + placeholder-color: inherit; +} + +/*****----- Listview -----*****/ +listview { + enabled: false; +} diff --git a/home/.config/bspwm/rofi/rasi/emoji/config.rasi b/home/.config/bspwm/rofi/rasi/emoji/config.rasi new file mode 100644 index 0000000..b8e3349 --- /dev/null +++ b/home/.config/bspwm/rofi/rasi/emoji/config.rasi @@ -0,0 +1,97 @@ +configuration { + display-drun: "Applications:"; + display-window: "Windows:"; + drun-display-format: "{icon} {name}"; + font: "JetBrainsMono Nerd Font Medium 10"; + modi: "window,run,drun"; + show-icons: true; + icon-theme: "Papirus"; + + /*---------- File browser settings ----------*/ + filebrowser { +/* directory: "/home";*/ + directories-first: true; + sorting-method: "name"; + } + + /*---------- Other settings ----------*/ + timeout { + action: "kb-cancel"; + delay: 0; + } + + /*---------- Keybindings ----------*/ + kb-primary-paste: "Control+V,Shift+Insert"; + kb-secondary-paste: "Control+v,Insert"; + kb-clear-line: "Control+w"; + kb-move-front: "Control+a"; + kb-move-end: "Control+e"; + kb-move-word-back: "Alt+b,Control+Left"; + kb-move-word-forward: "Alt+f,Control+Right"; + kb-move-char-back: "Left,Control+b"; + kb-move-char-forward: "Right,Control+f"; + kb-remove-word-back: "Control+Alt+h,Control+BackSpace"; + kb-remove-word-forward: "Control+Alt+d"; + kb-remove-char-forward: "Delete,Control+d"; + kb-remove-char-back: "BackSpace,Shift+BackSpace,Control+h"; + kb-remove-to-eol: "Control+k"; + kb-remove-to-sol: "Control+u"; + kb-accept-entry: "Control+j,Control+m,Return,KP_Enter"; + kb-accept-custom: "Control+Return"; + kb-accept-custom-alt: "Control+Shift+Return"; + kb-accept-alt: "Shift+Return"; + kb-delete-entry: "Shift+Delete"; + kb-mode-next: "Shift+Right,Control+Tab"; + kb-mode-previous: "Shift+Left,Control+ISO_Left_Tab"; + kb-mode-complete: "Control+l"; + kb-row-left: "Control+Page_Up"; + kb-row-right: "Control+Page_Down"; + kb-row-down: "Down,Control+n"; + kb-page-prev: "Page_Up"; + kb-page-next: "Page_Down"; + kb-row-first: "Home,KP_Home"; + kb-row-last: "End,KP_End"; + kb-row-select: "Control+space"; + kb-screenshot: "Super+Shift+S"; + kb-ellipsize: "Alt+period"; + kb-toggle-case-sensitivity: "grave,dead_grave"; + kb-toggle-sort: "Alt+grave"; + kb-cancel: "Escape,Control+g,Control+bracketleft"; + kb-custom-1: "Alt+1"; + kb-custom-2: "Alt+2"; + kb-custom-3: "Alt+3"; + kb-custom-4: "Alt+4"; + kb-custom-5: "Alt+5"; + kb-custom-6: "Alt+6"; + kb-custom-7: "Alt+7"; + kb-custom-8: "Alt+8"; + kb-custom-9: "Alt+9"; + kb-custom-10: "Alt+0"; + kb-custom-11: "Alt+exclam"; + kb-custom-12: "Alt+at"; + kb-custom-13: "Alt+numbersign"; + kb-custom-14: "Alt+dollar"; + kb-custom-15: "Alt+percent"; + kb-custom-16: "Alt+dead_circumflex"; + kb-custom-17: "Alt+ampersand"; + kb-custom-18: "Alt+asterisk"; + kb-custom-19: "Alt+parenleft"; + kb-select-1: "Control+1"; + kb-select-2: "Control+2"; + kb-select-3: "Control+3"; + kb-select-4: "Control+4"; + kb-select-5: "Control+5"; + kb-select-6: "Control+6"; + kb-select-7: "Control+7"; + kb-select-8: "Control+8"; + kb-select-9: "Control+9"; + kb-select-10: "Control+0"; + ml-row-left: "ScrollLeft"; + ml-row-right: "ScrollRight"; + ml-row-up: "ScrollUp"; + ml-row-down: "ScrollDown"; + me-select-entry: "MousePrimary"; + me-accept-entry: "MouseDPrimary"; + me-accept-custom: "Control+MouseDPrimary"; +} + diff --git a/home/.config/bspwm/rofi/rasi/emoji/emojimenu.rasi b/home/.config/bspwm/rofi/rasi/emoji/emojimenu.rasi new file mode 100644 index 0000000..613ff81 --- /dev/null +++ b/home/.config/bspwm/rofi/rasi/emoji/emojimenu.rasi @@ -0,0 +1,138 @@ +/*****----- Configuration -----*****/ +configuration { + show-icons: true; + drun-display-format: "{name}"; + window-format: "{w} · {c} · {t}"; +} + +/*****----- Global Properties -----*****/ +* { + font: "JetBrains Mono Nerd Font 11"; + background: #181825; + background-alt: #181825; + foreground: #cdd6f4; + selected: #11111b; + active: #89b4fa; + urgent: #11111b; +} + +/*****----- Main Window -----*****/ +window { + /* properties for window widget */ + transparency: "real"; + location: center; + anchor: center; + fullscreen: false; + width: 600px; + x-offset: 0px; + y-offset: 0px; + + /* properties for all widgets */ + enabled: true; + border-radius: 20px; + cursor: "default"; + background-color: @background; +} + +/*****----- Main Box -----*****/ +mainbox { + enabled: true; + spacing: 0px; + background-color: transparent; + orientation: vertical; + children: [ "inputbar", "listbox" ]; +} + +listbox { + padding: 10px 10px 10px 5px; + background-color: transparent; + orientation: vertical; + children: [ "listview" ]; +} + +/*****----- Inputbar -----*****/ +inputbar { + enabled: true; + spacing: 10px; + padding: 50px 40px; + background-color: transparent; + background-image: url("~/Pictures/hollow.jpg", width); + text-color: @foreground; + orientation: horizontal; + children: [ "textbox-prompt-colon", "entry"]; +} +textbox-prompt-colon { + enabled: true; + expand: false; + str: " "; + padding: 12px 11px 12px 19px; + border-radius: 100%; + background-color: @background-alt; + text-color: inherit; +} +entry { + enabled: true; + expand: false; + width: 470px; + padding: 12px 12px; + border-radius: 100%; + background-color: @background-alt; + text-color: inherit; + cursor: text; + placeholder: "Emoji"; + placeholder-color: inherit; +} + +/*****----- Listview -----*****/ +listview { + enabled: true; + columns: 1; + lines: 9; + cycle: true; + dynamic: true; + scrollbar: false; + layout: vertical; + reverse: false; + fixed-height: true; + fixed-columns: true; + + spacing: 5px; + background-color: transparent; + text-color: @foreground; + cursor: "default"; +} + +/*****----- Elements -----*****/ +element { + enabled: true; + padding: 5px; + spacing: 0px; + border-radius: 100%; + background-color: transparent; + text-color: @foreground; + cursor: pointer; +} +element normal.normal { + background-color: inherit; + text-color: inherit; +} + +element selected.normal { + background-color: @selected; + text-color: @foreground; +} + +element-icon { + background-color: transparent; + text-color: inherit; + size: 32px; + cursor: inherit; +} +element-text { + padding: 8px; + background-color: transparent; + text-color: inherit; + cursor: inherit; + vertical-align: 0.5; + horizontal-align: 0.0; +} diff --git a/home/.config/bspwm/rofi/rasi/launcher.rasi b/home/.config/bspwm/rofi/rasi/launcher.rasi new file mode 100755 index 0000000..7a78079 --- /dev/null +++ b/home/.config/bspwm/rofi/rasi/launcher.rasi @@ -0,0 +1,127 @@ +configuration { + font: "Iosevka Nerd Font 11"; + show-icons: true; + icon-theme: "Papirus"; + display-drun: " "; + drun-display-format: "{name}"; + disable-history: false; + fullscreen: false; + hide-scrollbar: true; + sidebar-mode: false; +} + +* { + bg:#2E3440; + bg1:#3B4252; + bg2:#434C5E; + bg3:#4C566A; + fg:#ECEFF4; + fg1:#E5E9F0; + fg2:#D8DEE9; + red: #BF616A; + orange:#D08770; + yellow:#EBCB8B; + magenta:#B48EAD; + cyan:#88C0D0; + blue:#81A1C1; + green:#A3BE8C; + transparent: #00000000; +} + +window { + transparency: "real"; + background-color: @bg; + text-color: @fg; + border: 3px; + border-color: @bg3; + border-radius: 12px; + width: 500px; + location: center; + x-offset: 0; + y-offset: 0; +} + +prompt { + enabled: true; + padding: 9px 0px 14px 14px; + background-color: @bg; + text-color: @fg2; + font: "Iosevka Nerd Font 17"; +} + +entry { + background-color: @bg; + text-color: @fg2; + placeholder-color: @bg2; + expand: true; + horizontal-align: 0; + placeholder: " Search..."; + padding: 15px 0px 0px 15px; + margin: 0px 250px 0px 0px; + border-radius: 0px 0px 0px 0px; + blink: true; +} + +inputbar { + children: [ prompt, entry ]; + background-color: @bg; + text-color: @fg2; + expand: false; + border: 0px; + border-radius: 12px; + border-color: @ac; + spacing: 0px; +} + +listview { + background-color: @bg1; + padding: 10px 10px 10px 10px; + columns: 1; + lines: 8; + spacing: 4px; + cycle: true; + dynamic: true; + layout: vertical; +} + +mainbox { + background-color: @bg; + border: 0px; + border-radius: 12px; + border-color: @bg1; + children: [ inputbar, listview ]; + spacing: 0px; + padding: 0px; +} + +element { + background-color: @bg1; + text-color: @fg; + orientation: horizontal; + border-radius: 0px; + padding: 8px 8px 8px 20px; +} + +element-icon { + size: 20px; + border: 0px; + background-color: @transparent; + text-color: @fg2; +} + +element-text { + expand: true; + horizontal-align: 0; + vertical-align: 0.5; + margin: 0px 2.5px 0px 2.5px; + background-color: @transparent; + text-color: @fg2; +} + +element selected { + background-color: @bg; + text-color: @fg; + border: 0 5px 0 5px; + border-radius: 0px; + border-color: @cyan; +} diff --git a/home/.config/bspwm/rofi/rasi/network.rasi b/home/.config/bspwm/rofi/rasi/network.rasi new file mode 100644 index 0000000..599db78 --- /dev/null +++ b/home/.config/bspwm/rofi/rasi/network.rasi @@ -0,0 +1,168 @@ +configuration { + show-icons: false; + display-drun: ""; + drun-display-format: "{icon} {name}"; + disable-history: false; + click-to-exit: true; +} + +* { + font: "Iosevka 10"; + background: #1A1B26; + foreground: #D4BFFF; + selected: #73A3DE; + background-alt: #D06FE8; + urgent: #E66D76; + active: #5EDEA3; + off: #E66D76; + BG: #1E1D2Fff; + BGA: #89DCEBff; + FG: #D9E0EEff; + FGA: #F28FADff; + BDR: #96CDFBff; + SEL: #1E1E2Eff; + UGT: #F28FADff; + IMG: #FAE3B0ff; + OFF: #575268ff; + ON: #ABE9B3ff; +} + +window { + transparency: "real"; + background-color: @BG; + text-color: @FG; + border: 2px; + border-color: @BDR; + border-radius: 10px; + width: 300px; + location: center; + anchor: center; + x-offset: 0; + y-offset: 0; +} + +prompt { + enabled: true; + margin: 0px 0px 0px 8px; + padding: 8px; + background-color: @BG; + text-color: @FG; + border: 0px 0px 2px 0px; + border-color: @BDR; + border-radius: 10px; +} + +textbox-prompt-colon { + expand: false; + str: ""; + border-radius: 100%; + background-color: @BG; + text-color: @FG; + padding: 8px 12px 8px 12px; + font: "Iosevka Nerd Font 10"; +} + +entry { + background-color: @BG; + text-color: @FG; + placeholder-color: @FG; + expand: true; + horizontal-align: 0; + placeholder: "Search..."; + blink: true; + border: 0px 0px 2px 0px; + border-color: @BDR; + border-radius: 10px; + padding: 8px; +} + +inputbar { + children: [ textbox-prompt-colon, prompt ]; + background-color: @BG; + text-color: @FG; + expand: false; + border: 0px 0px 0px 0px; + border-radius: 0px; + border-color: @BDR; + margin: 0px 0px 0px 0px; + padding: 0px; + position: center; +} + +case-indicator { + background-color: @BG; + text-color: @FG; + spacing: 0; +} + + +listview { + background-color: @BG; + columns: 1; + lines: 4; + spacing: 4px; + cycle: true; + dynamic: true; + layout: vertical; +} + +mainbox { + background-color: @BG; + children: [ inputbar, listview ]; + spacing: 15px; + padding: 15px; +} + +element { + background-color: @BG; + text-color: @FG; + orientation: horizontal; + border-radius: 10px; + padding: 6px 6px 6px 6px; +} + +element-icon { + background-color: inherit; + text-color: inherit; + size: 0px; + border: 0px; +} + +element-text { + background-color: inherit; + text-color: inherit; + expand: true; + horizontal-align: 0; + vertical-align: 0.5; + margin: 2px 0px 2px 6px; +} + +element selected { + background-color: @IMG; + text-color: @BG; + border: 0px 0px 0px 0px; + border-radius: 10px; + border-color: @BDR; +} + +element.active, +element.selected.urgent { + background-color: @ON; + text-color: @BG; + border-color: @ON; +} + +element.selected.urgent { + border-color: @BDR; +} + +element.urgent, +element.selected.active { + background-color: @OFF; + text-color: @BG; + border-color: @OFF; +} + +element.selected.active { + border-color: @BDR; +} diff --git a/home/.config/bspwm/rofi/rasi/networkmenu.rasi b/home/.config/bspwm/rofi/rasi/networkmenu.rasi new file mode 100644 index 0000000..ecd36c1 --- /dev/null +++ b/home/.config/bspwm/rofi/rasi/networkmenu.rasi @@ -0,0 +1,173 @@ + + +configuration { + font: "Iosevka 10"; + show-icons: false; + disable-history: false; + click-to-exit: true; +} + +* { + background: #1A1B26; + foreground: #D4BFFF; + selected: #73A3DE; + background-alt: #D06FE8; + urgent: #E66D76; + active: #5EDEA3; + off: #E66D76; + BG: #1E1D2Fff; + BGA: #89DCEBff; + FG: #D9E0EEff; + FGA: #F28FADff; + BDR: #96CDFBff; + SEL: #1E1E2Eff; + UGT: #F28FADff; + IMG: #FAE3B0ff; + OFF: #575268ff; + ON: #ABE9B3ff; +} + + +window { + transparency: "real"; + background-color: @background; + text-color: @foreground; + border: 2px; + border-color: @selected; + border-radius: 10px; + width: 400px; + location: center; + anchor: center; + x-offset: 0; + y-offset: 0; +} + +prompt { + enabled: true; + margin: 0px 0px 0px 8px; + padding: 6px 6px 6px 6px; + background-color: @selected; + text-color: @background; + border: 2px 2px 2px 2px; + border-color: @selected; + border-radius: 5px; +} + +textbox-prompt-colon { + expand: false; + str: " 直 "; + border-radius: 2px; + border-radius: 5px; + background-color: @selected; + text-color: @background; + padding: 6px 10px 6px 10px; + font: "Iosevka Nerd Font 10"; +} + +entry { + background-color: @selected; + text-color: @background; + margin: 0px 0px 0px 8px; + padding: 6px 6px 6px 6px; + border: 2px; + border-radius: 5px; + border-color: @selected; + placeholder-color: @background; + placeholder: " Search... "; + expand: true; + horizontal-align: 0; + blink: true; + padding: 6px; +} + +inputbar { + children: [ textbox-prompt-colon, prompt, entry ]; + spacing: 0; + background-color: @background; + text-color: @foreground; + expand: false; + margin: 0px 0px 0px 0px; + padding: 0px; + position: center; +} + +case-indicator { + background-color: @background; + text-color: @foreground; + spacing: 0; +} + + +listview { + background-color: @background; + columns: 1; + lines: 7; + spacing: 4px; + cycle: true; + dynamic: true; + layout: vertical; +} + +mainbox { + background-color: @background; + children: [ inputbar, listview ]; + spacing: 10px; + padding: 10px; +} + +element { + background-color: @background; + text-color: @foreground; + orientation: horizontal; + border-radius: 5px; + padding: 5px; +} + +element-icon { + background-color: inherit; + text-color: inherit; + horizontal-align: 0.5; + vertical-align: 0.5; + size: 0px; + border: 0px; +} + +element-text { + background-color: inherit; + text-color: inherit; + expand: true; + horizontal-align: 0; + vertical-align: 0; + margin: 2px 0px 2px 2px; +} + +element normal.urgent, +element alternate.urgent { + background-color: @urgent; + text-color: @foreground; + border-radius: 0px; +} + +element normal.active, +element alternate.active { + background-color: @background; + text-color: @foreground; +} + +element selected { + background-color: @selected; + text-color: @background; + border: 2px; + border-radius: 5px; + border-color: @selected; +} + +element selected.urgent { + background-color: @urgent; + text-color: @foreground; +} + +element selected.active { + background-color: @background; + color: @foreground; +} diff --git a/home/.config/bspwm/rofi/rasi/screenutils.rasi b/home/.config/bspwm/rofi/rasi/screenutils.rasi new file mode 100644 index 0000000..c71ca59 --- /dev/null +++ b/home/.config/bspwm/rofi/rasi/screenutils.rasi @@ -0,0 +1,128 @@ +configuration { + location: 4; + font: "JetBrains Mono Medium 20"; + show-icons: false; + display-drun: ""; + drun-display-format: "{icon} {name}"; + disable-history: false; + click-to-exit: true; +} + +* { +background: #1A1B26; +foreground: #D4BFFF; +darker: #161A1E; +lighter: #22262A; +pink: #FFDEDE; +red: #E5A3A1; +green: #B4E3AD; +blue: #A3CBE7; +selected: #73A3DE; +background-alt: #D06FE8; +urgent: #E66D76; +active: #5EDEA3; +off: #E66D76; + BG: #1E1D2Fff; + BGA: #89DCEBff; + FG: #D9E0EEff; + FGA: #F28FADff; + BDR: #96CDFBff; + SEL: #1E1E2Eff; + UGT: #F28FADff; + IMG: #FAE3B0ff; + OFF: #575268ff; + ON: #ABE9B3ff; +} + + +window { + transparency: "real"; + background-color: @background; + text-color: @foreground; + border: 2px; + border-color: @pink; + border-radius: 30px; + width: 100px; + x-offset: -10; + y-offset: 0; +} + +case-indicator { + background-color: @background; + text-color: @foreground; +} + +listview { + background-color: @background; + columns: 1; + spacing: 10px; + cycle: true; + dynamic: true; + layout: vertical; +} + +mainbox { + background-color: @background; + children: [ listview ]; + spacing: 10px; + padding: 20px; +} + +element { + background-color: @darker; + text-color: @foreground; + orientation: horizontal; + border-radius: 100%; + padding: 14px; +} + +element-icon { + background-color: inherit; + text-color: inherit; + horizontal-align: 0.5; + vertical-align: 0.5; + size: 0px; + border: 0px; +} + +element-text { + background-color: inherit; + text-color: inherit; + font: "Material Icons 30"; + expand: true; + horizontal-align: 0.5; + vertical-align: 0.5; + margin: 0px; +} + +element selected { + background-color: @pink; + text-color: @background; + border: 0px; + border-radius: 100%; + border-color: @pink; +} + +element.active, +element.selected.urgent { + background-color: @green; + text-color: @background; + border-color: @green; + border-radius: 100%; +} + +element.selected.urgent { + border-color: @pink; +} + +element.urgent, +element.selected.active { + background-color: @red; + text-color: @background; + border-color: @red; + border-radius: 100%; +} + +element.selected.active { + border-color: @pink; +} \ No newline at end of file diff --git a/home/.config/bspwm/rofi/rasi/sxhkd-help.rasi b/home/.config/bspwm/rofi/rasi/sxhkd-help.rasi new file mode 100644 index 0000000..efcca33 --- /dev/null +++ b/home/.config/bspwm/rofi/rasi/sxhkd-help.rasi @@ -0,0 +1,131 @@ + +configuration { + font: "SFMono Nerd Font 10"; + show-icons: true; + icon-theme: "Papirus"; + display-drun: ""; + drun-display-format: "CC"; + disable-history: false; + fullscreen: false; + hide-scrollbar: true; + sidebar-mode: false; +} + +* { + al: #3B4252FF; + bg: #3B4252FF; + bg1: #4C566AFF; + bg2: #434C5EFF; + bg3: #2E3440FF; + fg: #ECEFF4FF; + fg1: #a1a4abFF; + ac: #5E81ACFF; + inherit: #00000000; + blur: #3B425290; + border: #3B4252ff; + red: #BF616A; + orange:#D08770; + yellow:#EBCB8B; + magenta:#B48EAD; + cyan:#88C0D0; + blue:#81A1C1; + green:#A3BE8C; +} + +window { + transparency: "real"; + background-color: @blur; + text-color: @fg; + border: 3px; + border-color: @border; + border-radius: 0px; + width: 800px; + location: center; + x-offset: 0; + y-offset: 0; +} + +prompt { + enabled: true; + padding: 12px 15px 12px 15px; + background-color: @bg3; + text-color: @fg; + font: "SFMono Nerd Font 12"; +} + +entry { + background-color: @bg3; + text-color: @fg; + placeholder-color: @fg1; + expand: true; + horizontal-align: 0; + placeholder: " Search..."; + padding: 10px 10px 10px 10px; + margin: 0px 250px 0px 0px; + border-radius: 0px 50px 50px 0px; + blink: true; +} + +inputbar { + children: [ entry ]; + background-color: @bg3; + text-color: @fg; + expand: false; + border: 0px; + border-radius: 0px; + border-color: @ac; + spacing: 0px; +} + +listview { + background-color: @al; + padding: 10px 10px 10px 10px; + columns: 1; + lines: 10; + spacing: 4px; + cycle: true; + dynamic: true; + layout: vertical; +} + +mainbox { + background-color: @al; + border: 0px; + border-radius: 0px; + border-color: @bg4; + children: [ inputbar, listview ]; + spacing: 0px; + padding: 0px; +} + +element { + background-color: @inherit; + text-color: @fg; + orientation: horizontal; + border-radius: 0px; + padding: 5px; +} + +element-icon { + size: 0px; + border: 0px; + background-color: @inherit; + text-color: @fg; +} + +element-text { + expand: true; + horizontal-align: 0; + vertical-align: 0.5; + margin: 0px 2.5px 0px 2.5px; + background-color: @inherit; + text-color: @fg; +} + +element selected { + background-color: @bg1; + text-color: @ac; + border: 0 5px 0 5px; + border-radius: 0px; + border-color: @cyan; +} \ No newline at end of file diff --git a/home/.config/bspwm/rofi/rasi/window.rasi b/home/.config/bspwm/rofi/rasi/window.rasi new file mode 100644 index 0000000..c498ba8 --- /dev/null +++ b/home/.config/bspwm/rofi/rasi/window.rasi @@ -0,0 +1,178 @@ + + +configuration { + font: "Iosevka 10"; + show-icons: false; + display-window: "Windows :"; + window-format: "{w} · {c} · {t}"; + disable-history: false; + click-to-exit: true; +} + +* { +background: #1A1B26; +foreground: #D4BFFF; +darker: #161A1E; +lighter: #22262A; +pink: #FFDEDE; +red: #E5A3A1; +green: #B4E3AD; +blue: #A3CBE7; +selected: #73A3DE; +background-alt: #D06FE8; +urgent: #E66D76; +active: #5EDEA3; +off: #E66D76; + BG: #1E1D2Fff; + BGA: #89DCEBff; + FG: #D9E0EEff; + FGA: #F28FADff; + BDR: #96CDFBff; + SEL: #1E1E2Eff; + UGT: #F28FADff; + IMG: #FAE3B0ff; + OFF: #575268ff; + ON: #ABE9B3ff; +} + + +window { + transparency: "real"; + background-color: @background; + text-color: @foreground; + border: 2px; + border-color: @selected; + border-radius: 10px; + width: 500px; + location: center; + anchor: center; + x-offset: 0; + y-offset: 0; +} + +prompt { + enabled: true; + margin: 0px 0px 0px 8px; + padding: 6px 6px 6px 6px; + background-color: @selected; + text-color: @background; + border: 2px; + border-color: @selected; + border-radius: 5px; +} + +textbox-prompt-colon { + expand: false; + str: ""; + border-radius: 5px; + background-color: @selected; + text-color: @background; + padding: 6px 10px 6px 10px; + font: "Iosevka Nerd Font 10"; +} + +entry { + background-color: @selected; + text-color: @background; + margin: 0px 0px 0px 8px; + border: 2px; + border-radius: 5px; + border-color: @selected; + placeholder-color: @background; + placeholder: " Find... "; + expand: true; + horizontal-align: 0; + blink: true; + padding: 6px; +} + +inputbar { + children: [ textbox-prompt-colon, prompt, entry ]; + spacing: 0; + background-color: @background; + text-color: @foreground; + expand: false; + margin: 0px 0px 0px 0px; + padding: 0px; + position: center; +} + +case-indicator { + background-color: @background; + text-color: @foreground; + spacing: 0; +} + + +listview { + background-color: @background; + columns: 1; + lines: 7; + spacing: 5px; + cycle: true; + dynamic: true; + layout: vertical; +} + +mainbox { + background-color: @background; + children: [ inputbar, listview ]; + spacing: 10px; + padding: 10px; +} + +element { + background-color: @background; + text-color: @foreground; + orientation: horizontal; + border-radius: 5px; + padding: 5px; +} + +element-icon { + background-color: inherit; + text-color: inherit; + horizontal-align: 0.5; + vertical-align: 0.5; + size: 0px; + border: 0px; +} + +element-text { + background-color: inherit; + text-color: inherit; + expand: true; + horizontal-align: 0; + vertical-align: 0; + margin: 2px 0px 2px 2px; +} + +element selected { + background-color: @selected; + text-color: @background; + border: 0px; + border-radius: 5px; + border-color: @selected; +} + +element.active, +element.selected.urgent { + background-color: @active; + text-color: @background; + border-color: @active; +} + +element.selected.urgent { + border-color: @selected; +} + +element.urgent, +element.selected.active { + background-color: @off; + text-color: @background; + border-color: @off; +} + +element.selected.active { + border-color: @selected; +}