Skip to content

Commit

Permalink
Merge pull request #34 from H3rmt/master
Browse files Browse the repository at this point in the history
Added custom CSS
  • Loading branch information
H3rmt authored May 14, 2024
2 parents 28efc3d + f007323 commit d67d909
Show file tree
Hide file tree
Showing 28 changed files with 882 additions and 841 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "hyprswitch"
description = "A CLI/GUI that allows switching between windows in Hyprland"
version = "1.2.4"
version = "1.3.0"
edition = "2021"
license = "MIT"
readme = "README.md"
Expand All @@ -13,7 +13,7 @@ categories = ["command-line-utilities"]

[dependencies]
clap = { version = "^4.5.4", features = ["derive"] }
hyprland = { version = "0.4.0-alpha.1" }
hyprland = { version = "0.4.0-alpha.2" }
tokio = { version = "1.37.0", features = ["full"] }
log = "0.4.21"
stderrlog = "0.6.0"
Expand Down
2 changes: 1 addition & 1 deletion PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pkgname=hyprswitch
pkgver=1.2.4
pkgver=1.3.0
pkgrel=1
pkgdesc="A CLI/GUI that allows switching between windows in Hyprland"
arch=('any')
Expand Down
173 changes: 163 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ To use the GUI, you need to pass the `--daemon` flag to the script which will st
Subsequent calls to the script (with the `--daemon` flag) will send the command to the daemon which will execute the
command and update the GUI.

![image.png](image.png)
![image.png](imgs/image_2.png)

# Installation

### From Source

- gtk4 and [gtk4-layer-shell](https://github.com/wmww/gtk4-layer-shell) must be installed
- `cargo install hyprswitch`

### Arch
Expand All @@ -31,7 +32,7 @@ command and update the GUI.
- add ``hyprswitch.url = "github:h3rmt/hyprswitch/release";`` to flake inputs
- add `specialArgs = { inherit inputs; };` to `nixpkgs.lib.nixosSystem`
- add `inputs.hyprswitch.packages.x86_64-linux.default` to your `environment.systemPackages`
- availible systems: `aarch64-linux`, `i686-linux`, `riscv32-linux`, `riscv64-linux`, `x86_64-linux`
- available systems: `aarch64-linux`, `i686-linux`, `riscv32-linux`, `riscv64-linux`, `x86_64-linux`

# Usage

Expand All @@ -41,21 +42,29 @@ The script accepts these parameters:

- Sorting related
- `--reverse`/`-r` Reverse the order of windows / switch backwards
- `--filter-same-class`/`-s` Only switch between windows that have the same class/type as the currently focused window
- `--filter-current-workspace`/`-w` Only switch between windows that are on the same workspace as the currently focused window
- `--filter-current-monitor`/`-m` Only switch between windows that are on the same monitor as the currently focused window
- `--filter-same-class`/`-s` Only switch between windows that have the same class/type as the currently focused
window
- `--filter-current-workspace`/`-w` Only switch between windows that are on the same workspace as the currently
focused window
- `--filter-current-monitor`/`-m` Only switch between windows that are on the same monitor as the currently focused
window

- `--sort-recent` Sort windows by most recently focused (when used with `--daemon` it will use the order of windows when the daemon was started)
- `--sort-recent` Sort windows by most recently focused (when used with `--daemon` it will use the order of windows
when the daemon was started)

- `--ignore-workspaces` Sort all windows on every monitor like [one contiguous workspace](#--ignore-workspaces)
- `--ignore-monitors` Sort all windows on matching workspaces on monitors like [one big monitor](#--ignore-monitors), [workspaces must have offset of 10 for each monitor](#ignore-monitors-flag)
- `--ignore-monitors` Sort all windows on matching workspaces on monitors
like [one big monitor](#--ignore-monitors), [workspaces must have offset of 10 for each monitor](#ignore-monitors-flag)

- GUI related
- `--daemon` Starts as daemon, creates socket server and GUI, sends Command to the daemon if already running
- `--stop-daemon` Stops the daemon, sends stop to socket server, doesn't execute current window switch, executes the command to switch window if `--switch-on-close` is true
- `--stop-daemon` Stops the daemon, sends stop to socket server, doesn't execute current window switch, executes the
command to switch window if `--switch-on-close` is true
- `--do-initial-execute` Also execute the initial command when starting the daemon
- `--switch-ws-on-hover` Switch to workspaces when hovering over them in GUI
- `--switch-on-close` Execute the command to switch windows on close of daemon instead of switching for every command
- `--switch-on-close` Execute the command to switch windows on close of daemon instead of switching for every
command
- `--custom-css` Path to a css file to add [custom styles](CSS)

- `--offset`/`-o` Switch to a specific window offset (default 1)
- `--ignore-special-workspaces` Hide special workspaces (e.g. scratchpad)
Expand Down Expand Up @@ -228,6 +237,150 @@ See [tests](/tests) for more details on how windows get sorted
2 4 7 9
```

# CSS

### Class used:

- **client-image**
<table><tr><td>

```css
.client-image {
margin: 15px;
}
```
</td><td><img src="imgs/css_client-image.png"/> </td></tr></table>

- **client-index**
<table><tr><td>

```css
.client-index {
margin: 6px;
padding: 5px;
font-size: 30px;
font-weight: bold;
border-radius: 15px;
border: 3px solid rgba(130, 130, 180, 0.4);
background-color: rgba(20, 20, 20, 0.99);
}
```
</td><td><img src="imgs/css_client-index.png"/> </td></tr></table>

- **client** + **client_active**

client_active is the client that is currently focused / will be focused when exiting hyprswitch
<table><tr><td>

```css
.client {
border-radius: 15px;
border: 3px solid rgba(130, 130, 180, 0.4);
background-color: rgba(20, 20, 25, 0.85);
}
.client:hover {
background-color: rgba(30, 30, 30, 0.99);
}
.client_active {
border: 3px solid rgba(239, 9, 9, 0.94);
}
```
</td><td><img src="imgs/css_client.png"/> </td></tr></table>

- **workspace_frame** + **workspace_frame_special**

workspace_frame_special is added when workspaceId is < 0 (e.g., scratchpad)
<table><tr><td>

```css
.workspace {
font-size: 25px;
font-weight: bold;
border-radius: 15px;
border: 3px solid rgba(80, 80, 80, 0.4);
background-color: rgba(20, 20, 25, 0.85);
}
.workspace_special {
border: 3px solid rgba(0, 255, 0, 0.4);
}
```
</td><td><img src="imgs/css_workspace.png"/> </td></tr></table>

- **workspaces**
<table><tr><td>

```css
.workspaces {
margin: 10px;
}
```
</td><td><img src="imgs/css_workspaces.png"/> </td></tr></table>

- **window**
<table><tr><td>

```css
window {
border-radius: 15px;
opacity: 0.9;
border: 6px solid rgba(0, 0, 0, 0.4);
}
```
</td><td><img src="imgs/css_window.png"/> </td></tr></table>

### Complete config:
```css
.client-image {
margin: 15px;
}
.client-index {
margin: 6px;
padding: 5px;
font-size: 30px;
font-weight: bold;
border-radius: 15px;
border: 3px solid rgba(130, 130, 180, 0.4);
background-color: rgba(20, 20, 20, 0.99);
}
.client {
border-radius: 15px;
border: 3px solid rgba(130, 130, 180, 0.4);
background-color: rgba(20, 20, 25, 0.85);
}
.client:hover {
background-color: rgba(30, 30, 30, 0.99);
}
.client_active {
border: 3px solid rgba(239, 9, 9, 0.94);
}
.workspace {
font-size: 25px;
font-weight: bold;
border-radius: 15px;
border: 3px solid rgba(80, 80, 80, 0.4);
background-color: rgba(20, 20, 25, 0.85);
}
.workspace_special {
border: 3px solid rgba(0, 255, 0, 0.4);
}
.workspaces {
margin: 10px;
}
window {
border-radius: 15px;
opacity: 0.9;
border: 6px solid rgba(0, 0, 0, 0.4);
}
```

### Example:
```css
.client_active {
border: 3px solid rgba(239, 9, 9, 0.94);
background-color: rgba(200, 9, 9, 0.80);
}
```

# Other

### Ignore monitors flag
Expand Down Expand Up @@ -315,4 +468,4 @@ this can be configured in `~/.config/hypr/hyprland.conf` (https://wiki.hyprland.
the next index indicator
- `EXIT_ON_CLICK` bool [default: true]: Exit the GUI when clicking on a window
- `WORKSPACE_GAP` usize [default: 15]: Gap between workspaces in the GUI (cant be configured via CSS as the workspace
positions are calculated from the real workspace positions)
positions are calculated from the real workspace positions)
Binary file added imgs/css_client-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/css_client-index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/css_client.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/css_window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/css_workspace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/css_workspaces.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added imgs/image_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 3 additions & 18 deletions package.nix
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
{
lib,
pkgs,
pkg-config,
rustPlatform,
makeWrapper,
}: let
{ lib, pkgs, pkg-config, rustPlatform, makeWrapper }: let
package = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package;
in
rustPlatform.buildRustPackage rec {
name = package.name;
version = package.version;

src = lib.cleanSource ./.;

cargoLock.lockFile = ./Cargo.lock;

nativeBuildInputs = [
pkg-config
makeWrapper
];

buildInputs = with pkgs; [
glib
gtk4
gtk4-layer-shell
];
nativeBuildInputs = [ pkg-config makeWrapper ];
buildInputs = with pkgs; [ glib gtk4 gtk4-layer-shell ];

postInstall = ''
wrapProgram $out/bin/${name}
Expand Down
3 changes: 3 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
imports_granularity = "Crate"
imports_layout = "Mixed"
group_imports = "StdExternalCrate"
16 changes: 11 additions & 5 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::fmt::Debug;
use std::path::PathBuf;

use clap::Parser;

Expand Down Expand Up @@ -59,14 +60,19 @@ pub struct Args {
#[arg(long, default_value = "true", value_name = "bool", value_parser = clap::builder::PossibleValuesParser::new(["true", "false"]))]
#[cfg(feature = "gui")]
pub switch_on_close: String,

/// Specify a path to custom css file
#[arg(long)]
#[cfg(feature = "gui")]
pub custom_css: Option<PathBuf>,

/// Switch to a specific window offset
#[arg(short = 'o', long, default_value = "1")]
pub offset: u8,

/// Hide special workspaces (e.g. scratchpad) (default is true, pass false to disable)
#[arg(long, default_value = "true", value_name = "bool", value_parser = clap::builder::PossibleValuesParser::new(["true", "false"]))]
pub hide_special_workspaces: String,
/// Show special workspaces (e.g., scratchpad)
#[arg(long)]
pub show_special_workspaces: bool,

/// Print the command that would be executed
#[arg(short = 'd', long)]
Expand All @@ -88,7 +94,7 @@ impl From<Args> for Info {
filter_same_class: args.filter_same_class,
filter_current_workspace: args.filter_current_workspace,
filter_current_monitor: args.filter_current_monitor,
hide_special_workspaces: args.hide_special_workspaces == "true",
show_special_workspaces: args.show_special_workspaces,
}
}
}
}
Loading

0 comments on commit d67d909

Please sign in to comment.