This commit is contained in:
assada 2024-05-15 13:04:01 +03:00
parent 8f7983b376
commit d32bba2bd1
49 changed files with 0 additions and 13350 deletions

View File

@ -8,7 +8,6 @@
"modules-left": [
"custom/launcher",
"sway/workspaces",
// "custom/swap",
"tray",
"sway/mode",
],
@ -46,65 +45,6 @@
"10": ""
}
},
"mpd": {
"tooltip": true,
"tooltip-format": "{artist} - {album} - {title} - Total Time : {totalTime:%M:%S}",
"format": " {elapsedTime:%M:%S}",
"format-disconnected": "⚠ Disconnected",
"format-stopped": " Not Playing",
"on-click": "mpc toggle",
"state-icons": {
"playing": "",
"paused": ""
}
},
"mpd#2": {
"format": "",
"format-disconnected": "",
"format-paused": "",
"format-stopped": "",
// Commands to execute on events
"on-click": "mpc -q pause && mpc -q prev && mpc -q start"
},
"mpd#3": {
"interval": 1,
"format": "{stateIcon}",
"format-disconnected": "",
"format-paused": "{stateIcon}",
"format-stopped": "",
"state-icons": {
"paused": "",
"playing": ""
},
// Commands to execute on events
"on-click": "mpc toggle"
},
"mpd#4": {
"format": "",
"format-disconnected": "",
"format-paused": "",
"format-stopped": "",
// Commands to execute on events
"on-click": "mpc -q pause && mpc -q next && mpc -q start"
},
"custom/swap": {
"on-click": "~/.config/sway/waybar/scripts/swap.sh",
"tooltip": "Swap between waybar configs",
"format": "Bg  "
},
"custom/mpd": {
"format": " {title} - {artist}",
"interval": 5,
"exec": "mpc current --format='\"title\":\"%title%\",\"artist\":\"%artist%\"'"
},
"custom/cava-internal": {
"exec": "sh ~/.config/sway/waybar/scripts/Cava.sh",
"format": "{}",
"tooltip": false,
//"on-click": "swaymsg reload & pkill waybar & waybar",
"layer": "below",
"output": "all"
},
"sway/mode": {
"format": "<span style=\"italic\">{}</span>"
},
@ -152,33 +92,6 @@
// //"max-length": 200
"interval": 1
},
// "clock": {
// "format": " {:%H:%M:%S}",
// "format-alt": " {:%A, %B %d, %Y (%R)}",
// "tooltip-format": "<tt><small>{calendar}</small></tt>",
// "calendar": {
// "mode" : "month",
// "mode-mon-col" : 3,
// "weeks-pos" : "right",
// "on-scroll" : 1,
// "on-click-right": "mode",
// "format": {
// "months": "<span color='#ffead3'><b>{}</b></span>",
// "days": "<span color='#ecc6d9'><b>{}</b></span>",
// "weeks": "<span color='#99ffdd'><b>W{}</b></span>",
// "weekdays": "<span color='#ffcc66'><b>{}</b></span>",
// "today": "<span color='#ff6699'><b><u>{}</u></b></span>"
// }
// },
// "actions": {
// "on-click-right": "mode",
// "on-click-forward": "tz_up",
// "on-click-backward": "tz_down",
// "on-scroll-up": "shift_up",
// "on-scroll-down": "shift_down"
// },
// "interval": 1
// },
"cpu": {
"interval": 10,
"format": " {}%",
@ -245,14 +158,6 @@
"on-scroll-up": "pamixer -ui 2 && pamixer --get-volume > $SWAYSOCK.wob",
"on-scroll-down": "pamixer -ud 2 && pamixer --get-volume > $SWAYSOCK.wob"
},
"custom/pacman": {
"format": " {}",
"interval": 7200, // every two hours
"exec": "i=$(checkupdates); echo \"$i\" |wc -l; echo \"$i\" |column -t |tr '\n' '\r'", // # of updates and tooltip details
"exec-if": "exit 0", // always run; consider advanced run conditions
"on-click": "alacritty -e sudo pacman -Syu", // update system
"signal": 8
},
"custom/power": {
"format": "󰐥",
"on-click": "nwgbar -layer-shell-layer OVERLAY -layer-shell-exclusive-zone -1 -b 24273a -o 0.8",

View File

@ -1,278 +0,0 @@
{
"layer": "top", // Waybar at top layer
"position": "top", // Waybar position (top|bottom|left|right)
"height": 30,
"margin": "0 0 0 0",
//"width": 1350, // Waybar width
// Choose the order of the modules idle_inhibitor
"modules-left": [
"custom/launcher",
"sway/workspaces",
"custom/swap",
"tray",
"sway/mode",
"custom/cava-internal",
"mpd#2",
"mpd#3",
"mpd#4",
"mpd"
],
"modules-center": ["clock"],
"modules-right": [
"backlight",
"pulseaudio",
"custom/keyboard-layout",
"temperature",
"memory",
"battery",
"network",
"custom/power"
],
// Modules configuration
"sway/workspaces": {
"disable-scroll": true,
"all-outputs": true,
"format": "{icon}",
// "format": "< %g >",
// "format_focused" : "< %g ● >",
"format-icons": {
"1": "",
"2": "󰈹",
"3": "",
"4": "",
"5": "",
"6": "",
"7": "",
"8": "",
"9": "",
"10": ""
}
},
"mpd": {
"tooltip": true,
"tooltip-format": "{artist} - {album} - {title} - Total Time : {totalTime:%M:%S}",
"format": " {elapsedTime:%M:%S}",
"format-disconnected": "⚠ Disconnected",
"format-stopped": " Not Playing",
"on-click": "mpc toggle",
"state-icons": {
"playing": "",
"paused": ""
}
},
"mpd#2": {
"format": "",
"format-disconnected": "",
"format-paused": "",
"format-stopped": "",
// Commands to execute on events
"on-click": "mpc -q pause && mpc -q prev && mpc -q start"
},
"mpd#3": {
"interval": 1,
"format": "{stateIcon}",
"format-disconnected": "",
"format-paused": "{stateIcon}",
"format-stopped": "",
"state-icons": {
"paused": "",
"playing": ""
},
// Commands to execute on events
"on-click": "mpc toggle"
},
"mpd#4": {
"format": "",
"format-disconnected": "",
"format-paused": "",
"format-stopped": "",
// Commands to execute on events
"on-click": "mpc -q pause && mpc -q next && mpc -q start"
},
"custom/swap": {
"on-click": "~/.config/sway/waybar/scripts/swap.sh",
"tooltip": "Swap between waybar configs",
"format": "Bg  "
},
"custom/mpd": {
"format": " {title} - {artist}",
"interval": 5,
"exec": "mpc current --format='\"title\":\"%title%\",\"artist\":\"%artist%\"'"
},
"custom/cava-internal": {
"exec": "sh ~/.config/sway/waybar/scripts/Cava.sh",
"format": "{}",
"tooltip": false,
//"on-click": "swaymsg reload & pkill waybar & waybar",
"layer": "below",
"output": "all"
},
"sway/mode": {
"format": "<span style=\"italic\">{}</span>"
},
"sway/window": {
"format": "~ {app_id}"
},
"idle_inhibitor": {
"format": "{icon}",
"format-icons": {
"activated": "",
"deactivated": ""
}
},
"tray": {
"icon-size": 14,
"spacing": 5
},
"clock": {
"tooltip-format": "<tt><small>{calendar}</small></tt>",
"calendar": {
"mode": "month",
"mode-mon-col": 3,
"weeks-pos": "right",
"on-scroll": 1,
"on-click-right": "mode",
"format": {
"months": "<span color='#ffead3'><b>{}</b></span>",
"days": "<span color='#ecc6d9'><b>{}</b></span>",
"weeks": "<span color='#99ffdd'><b>W{}</b></span>",
"weekdays": "<span color='#ffcc66'><b>{}</b></span>",
"today": "<span color='#ff6699'><b><u>{}</u></b></span>"
}
},
"actions": {
"on-click-right": "mode",
"on-click-forward": "tz_up",
"on-click-backward": "tz_down",
"on-scroll-up": "shift_up",
"on-scroll-down": "shift_down"
},
"format": " {:%a %d %b  %I:%M %p}", //12 hour format
// "format": " {:%d %m %Y  %H:%M}", //24 hour format
"format-alt": " {:%d/%m/%Y  %H:%M:%S}",
// //"timezones": [ "Kolkata" ],
// //"max-length": 200
"interval": 1
},
// "clock": {
// "format": " {:%H:%M:%S}",
// "format-alt": " {:%A, %B %d, %Y (%R)}",
// "tooltip-format": "<tt><small>{calendar}</small></tt>",
// "calendar": {
// "mode" : "month",
// "mode-mon-col" : 3,
// "weeks-pos" : "right",
// "on-scroll" : 1,
// "on-click-right": "mode",
// "format": {
// "months": "<span color='#ffead3'><b>{}</b></span>",
// "days": "<span color='#ecc6d9'><b>{}</b></span>",
// "weeks": "<span color='#99ffdd'><b>W{}</b></span>",
// "weekdays": "<span color='#ffcc66'><b>{}</b></span>",
// "today": "<span color='#ff6699'><b><u>{}</u></b></span>"
// }
// },
// "actions": {
// "on-click-right": "mode",
// "on-click-forward": "tz_up",
// "on-click-backward": "tz_down",
// "on-scroll-up": "shift_up",
// "on-scroll-down": "shift_down"
// },
// "interval": 1
// },
"cpu": {
"format": "﬙ {usage: >3}%",
"on-click": "alacritty -e htop"
},
"memory": {
"format": "󰍛 {: >3}%",
"on-click": "alacritty -e htop"
},
"temperature": {
// "thermal-zone": 2,
"hwmon-path": "/sys/class/hwmon/hwmon1/temp1_input",
"critical-threshold": 80,
// "format-critical": "{temperatureC}°C ",
"format": " {temperatureC}°C"
},
"backlight": {
// "device": "acpi_video1",
"format": "{icon} {percent: >3}%",
"format-icons": ["", ""],
// "on-scroll-down": "brightnessctl -c backlight set 5%-",
"on-scroll-down": "light -A 5 && light -G | cut -d'.' -f1 > $SWAYSOCK.wob",
// "on-scroll-up": "brightnessctl -c backlight set +5%"
"on-scroll-up": "light -U 5 && light -G | cut -d'.' -f1 > $SWAYSOCK.wob"
},
"battery": {
"states": {
// "good": 95,
"warning": 30,
"critical": 15
},
"format": "{icon} {capacity: >3}%",
// "format-good": "", // An empty format will hide the module
// "format-full": "",
"format-icons": ["", "", "", "", ""]
//"format-icons": ["", "", "", "", "", "", "", "", "", ""]
},
"network": {
// "interface": "wlp2s0", // (Optional) To force the use of this interface
"format": "⚠ Disabled",
"format-wifi": " {essid}",
// "format-ethernet": " {ifname}: {ipaddr}/{cidr}",
"format-ethernet": " Wired",
"format-disconnected": "⚠ Disconnected",
// "on-click": "alacritty -e nmtui"
"on-click": "nm-connection-editor"
},
"pulseaudio": {
"scroll-step": 1,
"format": "{icon} {volume: >3}%",
"format-bluetooth": "{icon} {volume: >3}%",
"format-muted": " muted",
"format-icons": {
"headphones": "",
"handsfree": "",
"headset": "",
"phone": "",
"portable": "",
"car": "",
"default": ["", ""]
},
"on-click": "pavucontrol",
"on-scroll-up": "pamixer -ui 2 && pamixer --get-volume > $SWAYSOCK.wob",
"on-scroll-down": "pamixer -ud 2 && pamixer --get-volume > $SWAYSOCK.wob"
},
"custom/pacman": {
"format": " {}",
"interval": 7200, // every two hours
"exec": "i=$(checkupdates); echo \"$i\" |wc -l; echo \"$i\" |column -t |tr '\n' '\r'", // # of updates and tooltip details
"exec-if": "exit 0", // always run; consider advanced run conditions
"on-click": "alacritty -e sudo pacman -Syu", // update system
"signal": 8
},
"custom/power": {
"format": "󰐥",
"on-click": "nwgbar",
"tooltip": false
},
"custom/keyboard-layout": {
"exec": "swaymsg -t get_inputs | grep -m1 'xkb_active_layout_name' | cut -d '\"' -f4",
// Interval set only as a fallback, as the value is updated by signal
"interval": 1,
"format": " {}", // Icon: keyboard
// Signal sent by Sway key binding (~/.config/sway/key-bindings)
"signal": 1, // SIGHUP
"tooltip": false,
"on-click": "~/.config/waybar/scripts/keyhint.sh"
},
"custom/launcher": {
"format": " ",
"on-click": "exec nwg-drawer -c 7 -is 70 -spacing 23",
"tooltip": false
}
}

View File

@ -1,2 +0,0 @@
#!/bin/sh
yad --title="null keybindings:" --no-buttons --geometry=600x345-15-400 --list --column=key: --column=description: --column=command: "ESC" "close this app" "" "=" "modkey" "(set mod Mod4)" "+enter" "Terminal" "(termite)" "+d" "Application Menu" "(rofi)" "+o" "" "Open Broswer" "+n" "" "Open Files" "+q" "close focused app" "(kill)" "[Shift]+Print-key" "screenshot" "(grim)" "+Shift+e" "power-menu" "(wofi)" "+Shift+p" "open keybinding helper" "full list"

View File

@ -1,22 +0,0 @@
#!/bin/bash
# Set the path to the config and style files
config_file="${HOME}/.config/sway/waybar/config"
config_background_file="${HOME}/.config/sway/waybar/config-background"
style_file="${HOME}/.config/sway/waybar/style.css"
style_background_file="${HOME}/.config/sway/waybar/style-background.css"
# Swap names of config files
mv "${config_file}" "${config_file}.temp"
mv "${config_background_file}" "${config_file}"
mv "${config_file}.temp" "${config_background_file}"
# Swap names of style files
mv "${style_file}" "${style_file}.temp"
mv "${style_background_file}" "${style_file}"
mv "${style_file}.temp" "${style_background_file}"
echo "File names swapped successfully!"
pkill waybar
~/.config/sway/scripts/statusbar &

View File

@ -1,13 +0,0 @@
image: debian/sid
packages:
- build-essential
- libwayland-dev
- libgtk-3-dev
- pkgconf
- meson
tasks:
- build: |
cd wofi
meson setup build
ninja -C build

View File

@ -1,8 +0,0 @@
^\.cproject$
^\.project$
^\.settings$
^\.hgrepos$
^build$
^debug$
^Debug$
^noasan$

View File

@ -1,12 +0,0 @@
b5784591ff8262c9d2752e2d764ca001a8ab18a8 v1.0
0e605f0b5b21ec77c9657d476d7c21856b284048 v1.1
fc1124ee262b729ce6fee9f110ba7d7c7d11c82f v1.1.1
96d47bb081be70e8866da71b5c9200f05f11557b v1.1.2
afda93e153f6f393f441d8f42a7d0f66ea8f061a v1.2
d24ec159f64442dd28774417295b2aa04bed76c6 v1.2.1
b352d73b652aadd3b9da064267d6f3fa26007c25 v1.2.2
e208549963dcd4ae89a18290aa598814c0b8eeb7 v1.2.3
84e91980936bf85a854cee6881398cff9d27fce4 v1.2.4
1c32143a8460e01559e141c291500a6f4ddcf18c v1.3
eab2b31e805564012e4f71920a8f87ba5f9f798c v1.4
1e89e8a94806ef2dd27dbf79b4fcc9902f89c422 v1.4.1

View File

@ -1,675 +0,0 @@
### GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
### Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom
to share and change all versions of a program--to make sure it remains
free software for all its users. We, the Free Software Foundation, use
the GNU General Public License for most of our software; it applies
also to any other work released this way by its authors. You can apply
it to your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you
have certain responsibilities if you distribute copies of the
software, or if you modify it: responsibilities to respect the freedom
of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the
manufacturer can do so. This is fundamentally incompatible with the
aim of protecting users' freedom to change the software. The
systematic pattern of such abuse occurs in the area of products for
individuals to use, which is precisely where it is most unacceptable.
Therefore, we have designed this version of the GPL to prohibit the
practice for those products. If such problems arise substantially in
other domains, we stand ready to extend this provision to those
domains in future versions of the GPL, as needed to protect the
freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish
to avoid the special danger that patents applied to a free program
could make it effectively proprietary. To prevent this, the GPL
assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
### TERMS AND CONDITIONS
#### 0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds
of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of
an exact copy. The resulting work is called a "modified version" of
the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user
through a computer network, with no transfer of a copy, is not
conveying.
An interactive user interface displays "Appropriate Legal Notices" to
the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
#### 1. Source Code.
The "source code" for a work means the preferred form of the work for
making modifications to it. "Object code" means any non-source form of
a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users can
regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same
work.
#### 2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey,
without conditions so long as your license otherwise remains in force.
You may convey covered works to others for the sole purpose of having
them make modifications exclusively for you, or provide you with
facilities for running those works, provided that you comply with the
terms of this License in conveying all material for which you do not
control copyright. Those thus making or running the covered works for
you must do so exclusively on your behalf, under your direction and
control, on terms that prohibit them from making any copies of your
copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the
conditions stated below. Sublicensing is not allowed; section 10 makes
it unnecessary.
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such
circumvention is effected by exercising rights under this License with
respect to the covered work, and you disclaim any intention to limit
operation or modification of the work as a means of enforcing, against
the work's users, your or third parties' legal rights to forbid
circumvention of technological measures.
#### 4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
#### 5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these
conditions:
- a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
- b) The work must carry prominent notices stating that it is
released under this License and any conditions added under
section 7. This requirement modifies the requirement in section 4
to "keep intact all notices".
- c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
- d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
#### 6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of
sections 4 and 5, provided that you also convey the machine-readable
Corresponding Source under the terms of this License, in one of these
ways:
- a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
- b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the Corresponding
Source from a network server at no charge.
- c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
- d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
- e) Convey the object code using peer-to-peer transmission,
provided you inform other peers where the object code and
Corresponding Source of the work are being offered to the general
public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal,
family, or household purposes, or (2) anything designed or sold for
incorporation into a dwelling. In determining whether a product is a
consumer product, doubtful cases shall be resolved in favor of
coverage. For a particular product received by a particular user,
"normally used" refers to a typical or common use of that class of
product, regardless of the status of the particular user or of the way
in which the particular user actually uses, or expects or is expected
to use, the product. A product is a consumer product regardless of
whether the product has substantial commercial, industrial or
non-consumer uses, unless such uses represent the only significant
mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to
install and execute modified versions of a covered work in that User
Product from a modified version of its Corresponding Source. The
information must suffice to ensure that the continued functioning of
the modified object code is in no case prevented or interfered with
solely because modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or
updates for a work that has been modified or installed by the
recipient, or for the User Product in which it has been modified or
installed. Access to a network may be denied when the modification
itself materially and adversely affects the operation of the network
or violates the rules and protocols for communication across the
network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
#### 7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders
of that material) supplement the terms of this License with terms:
- a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
- b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
- c) Prohibiting misrepresentation of the origin of that material,
or requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
- d) Limiting the use for publicity purposes of names of licensors
or authors of the material; or
- e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
- f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions
of it) with contractual assumptions of liability to the recipient,
for any liability that these contractual assumptions directly
impose on those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions; the
above requirements apply either way.
#### 8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
#### 9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run
a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
#### 10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
#### 11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned
or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within the
scope of its coverage, prohibits the exercise of, or is conditioned on
the non-exercise of one or more of the rights that are specifically
granted under this License. You may not convey a covered work if you
are a party to an arrangement with a third party that is in the
business of distributing software, under which you make payment to the
third party based on the extent of your activity of conveying the
work, and under which the third party grants, to any of the parties
who would receive the covered work from you, a discriminatory patent
license (a) in connection with copies of the covered work conveyed by
you (or copies made from those copies), or (b) primarily for and in
connection with specific products or compilations that contain the
covered work, unless you entered into that arrangement, or that patent
license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
#### 12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under
this License and any other pertinent obligations, then as a
consequence you may not convey it at all. For example, if you agree to
terms that obligate you to collect a royalty for further conveying
from those to whom you convey the Program, the only way you could
satisfy both those terms and this License would be to refrain entirely
from conveying the Program.
#### 13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
#### 14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions
of the GNU General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in
detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies that a certain numbered version of the GNU General Public
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that numbered version or
of any later version published by the Free Software Foundation. If the
Program does not specify a version number of the GNU General Public
License, you may choose any version ever published by the Free
Software Foundation.
If the Program specifies that a proxy can decide which future versions
of the GNU General Public License can be used, that proxy's public
statement of acceptance of a version permanently authorizes you to
choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
#### 15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
#### 16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#### 17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
### How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively state
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper
mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands \`show w' and \`show c' should show the
appropriate parts of the General Public License. Of course, your
program's commands might be different; for a GUI interface, you would
use an "about box".
You should also get your employer (if you work as a programmer) or
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. For more information on this, and how to apply and follow
the GNU GPL, see <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your
program into proprietary programs. If your program is a subroutine
library, you may consider it more useful to permit linking proprietary
applications with the library. If this is what you want to do, use the
GNU Lesser General Public License instead of this License. But first,
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -1,43 +0,0 @@
# Wofi
Wofi is a launcher/menu program for wlroots based wayland compositors such as sway
[![builds.sr.ht status](https://builds.sr.ht/~scoopta/wofi.svg)](https://builds.sr.ht/~scoopta/wofi?)
## Dependencies
libwayland-dev
libgtk-3-dev
pkgconf
meson
## Building
hg clone https://hg.sr.ht/~scoopta/wofi
cd wofi
meson setup build
ninja -C build
## Installing
sudo ninja -C build install
## Uninstalling
sudo ninja -C build uninstall
## Bug Reports
Please file bug reports at https://todo.sr.ht/~scoopta/wofi
## Contributing
Please submit patches to https://lists.sr.ht/~scoopta/wofi
You can find documentation here https://man.sr.ht/hg.sr.ht/email.md
## drun and dbus
Some desktop files declare themselves as being launched by dbus, if this is the case wofi can experience issues on systems where a user session bus is not automatically started such as systems using elogind.
To manually launch a user session bus run the following:
dbus-daemon --session --address=unix:path=$XDG_RUNTIME_DIR/bus
## Packages
[![Packaging status](https://repology.org/badge/vertical-allrepos/wofi.svg)](https://repology.org/project/wofi/versions)
## Documentation
The official documentation is provided by the man pages in this repository, sample styling can be found here https://cloudninja.pw/docs/wofi.html
## Donating
If you feel like supporting development you can donate at https://ko-fi.com/scoopta
## Screenshots
[![example 4](https://f.cloudninja.pw/Scaled_4.png)](https://f.cloudninja.pw/Rootbar_Example_4.png)

BIN
wofi/build/wofi Executable file

Binary file not shown.

View File

@ -1,33 +0,0 @@
/*
* Copyright (C) 2019-2024 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_H
#define CONFIG_H
#include <stdint.h>
#include <map.h>
void config_put(struct map* map, char* line);
void config_load(struct map* map, const char* config);
char* config_get(struct map* config, const char* key, char* def_opt);
int config_get_mnemonic(struct map* config, const char* key, char* def_opt, int num_choices, ...);
#endif

View File

@ -1,40 +0,0 @@
/*
* Copyright (C) 2019-2020 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MAP_H
#define MAP_H
#include <stddef.h>
#include <stdbool.h>
struct map* map_init(void);
struct map* map_init_void(void);
void map_free(struct map* map);
bool map_put(struct map* map, const char* key, char* value);
bool map_put_void(struct map* map, const char* key, void* value);
void* map_get(struct map* map, const char* key);
bool map_contains(struct map* map, const char* key);
size_t map_size(struct map* map);
#endif

View File

@ -1,40 +0,0 @@
/*
* Copyright (C) 2019-2022 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MATCH_H
#define MATCH_H
#include <math.h>
#include <stdbool.h>
typedef double score_t;
#define SCORE_MAX INFINITY
#define SCORE_MIN -INFINITY
#define MATCH_FUZZY_MAX_LEN 256
#define MAX_MULTI_CONTAINS_FILTER_SIZE 256
enum matching_mode {
MATCHING_MODE_CONTAINS,
MATCHING_MODE_MULTI_CONTAINS,
MATCHING_MODE_FUZZY
};
int sort_for_matching_mode(const char *text1, const char *text2, int fallback,
enum matching_mode match_type, const char *filter, bool insensitive);
bool match_for_matching_mode(const char* filter, const char* text, enum matching_mode matching, bool insensitive);
#endif

View File

@ -1,33 +0,0 @@
/*
* Copyright (C) 2019-2020 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROPERTY_BOX_H
#define PROPERTY_BOX_H
#include <gtk/gtk.h>
#define WOFI_TYPE_PROPERTY_BOX wofi_property_box_get_type()
G_DECLARE_FINAL_TYPE(WofiPropertyBox, wofi_property_box, WOFI, PROPERTY_BOX, GtkBox)
GtkWidget* wofi_property_box_new(GtkOrientation orientation, gint spacing);
void wofi_property_box_add_property(WofiPropertyBox* this, const gchar* key, gchar* value);
const gchar* wofi_property_box_get_property(WofiPropertyBox* this, const gchar* key);
#endif

View File

@ -1,39 +0,0 @@
/*
* Copyright (C) 2019-2020 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UTIL_H
#define UTIL_H
#include <time.h>
#include <sys/types.h>
time_t utils_get_time_millis(void);
void utils_sleep_millis(time_t millis);
char* utils_concat(size_t arg_count, ...);
size_t utils_min(size_t n1, size_t n2);
size_t utils_min3(size_t n1, size_t n2, size_t n3);
size_t utils_distance(const char* haystack, const char* needle);
void utils_mkdir(char *path, mode_t mode);
#endif

View File

@ -1,29 +0,0 @@
/*
* Copyright (C) 2020 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UTILS_G_H
#define UTILS_G_H
#include <stdint.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
GdkPixbuf* utils_g_resize_pixbuf(GdkPixbuf* pixbuf, uint64_t image_size, GdkInterpType interp);
GdkPixbuf* utils_g_pixbuf_from_base64(char* base64);
#endif

View File

@ -1,32 +0,0 @@
/*
* Copyright (C) 2020 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WIDGET_BUILDER_H
#define WIDGET_BUILDER_H
#include <widget_builder_api.h>
#include <property_box.h>
struct widget_builder {
WofiPropertyBox* box;
struct widget* widget;
struct mode* mode;
size_t actions;
};
#endif

View File

@ -1,52 +0,0 @@
/*
* Copyright (C) 2020-2022 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WIDGET_BUILDER_API_H
#define WIDGET_BUILDER_API_H
#include <stddef.h>
#include <wofi_api.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
struct css_class {
char* class;
struct wl_list link;
};
struct widget_builder* wofi_widget_builder_init(struct mode* mode, size_t actions);
void wofi_widget_builder_set_search_text(struct widget_builder* builder, char* search_text);
void wofi_widget_builder_set_action(struct widget_builder* builder, char* action);
__attribute__((sentinel)) void wofi_widget_builder_insert_text(struct widget_builder* builder, const char* text, ...);
void wofi_widget_builder_insert_text_with_list(struct widget_builder* builder, const char* text, struct wl_list* classes);
__attribute__((sentinel)) void wofi_widget_builder_insert_image(struct widget_builder* builder, GdkPixbuf* pixbuf, ...);
void wofi_widget_builder_insert_image_with_list(struct widget_builder* builder, GdkPixbuf* pixbuf, struct wl_list* classes);
struct widget_builder* wofi_widget_builder_get_idx(struct widget_builder* builder, size_t idx);
struct widget* wofi_widget_builder_get_widget(struct widget_builder* builder);
void wofi_widget_builder_free(struct widget_builder* builder);
#endif

View File

@ -1,559 +0,0 @@
/* Generated by wayland-scanner 1.16.0 */
#ifndef WLR_LAYER_SHELL_V1_UNSTABLE_V1_CLIENT_PROTOCOL_H
#define WLR_LAYER_SHELL_V1_UNSTABLE_V1_CLIENT_PROTOCOL_H
#include <stdint.h>
#include <stddef.h>
#include "wayland-client.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @page page_wlr_layer_shell_v1_unstable_v1 The wlr_layer_shell_v1_unstable_v1 protocol
* @section page_ifaces_wlr_layer_shell_v1_unstable_v1 Interfaces
* - @subpage page_iface_zwlr_layer_shell_v1 - create surfaces that are layers of the desktop
* - @subpage page_iface_zwlr_layer_surface_v1 - layer metadata interface
* @section page_copyright_wlr_layer_shell_v1_unstable_v1 Copyright
* <pre>
*
* Copyright © 2017 Drew DeVault
*
* Permission to use, copy, modify, distribute, and sell this
* software and its documentation for any purpose is hereby granted
* without fee, provided that the above copyright notice appear in
* all copies and that both that copyright notice and this permission
* notice appear in supporting documentation, and that the name of
* the copyright holders not be used in advertising or publicity
* pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied
* warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
* </pre>
*/
struct wl_output;
struct wl_surface;
struct xdg_popup;
struct zwlr_layer_shell_v1;
struct zwlr_layer_surface_v1;
/**
* @page page_iface_zwlr_layer_shell_v1 zwlr_layer_shell_v1
* @section page_iface_zwlr_layer_shell_v1_desc Description
*
* Clients can use this interface to assign the surface_layer role to
* wl_surfaces. Such surfaces are assigned to a "layer" of the output and
* rendered with a defined z-depth respective to each other. They may also be
* anchored to the edges and corners of a screen and specify input handling
* semantics. This interface should be suitable for the implementation of
* many desktop shell components, and a broad number of other applications
* that interact with the desktop.
* @section page_iface_zwlr_layer_shell_v1_api API
* See @ref iface_zwlr_layer_shell_v1.
*/
/**
* @defgroup iface_zwlr_layer_shell_v1 The zwlr_layer_shell_v1 interface
*
* Clients can use this interface to assign the surface_layer role to
* wl_surfaces. Such surfaces are assigned to a "layer" of the output and
* rendered with a defined z-depth respective to each other. They may also be
* anchored to the edges and corners of a screen and specify input handling
* semantics. This interface should be suitable for the implementation of
* many desktop shell components, and a broad number of other applications
* that interact with the desktop.
*/
extern const struct wl_interface zwlr_layer_shell_v1_interface;
/**
* @page page_iface_zwlr_layer_surface_v1 zwlr_layer_surface_v1
* @section page_iface_zwlr_layer_surface_v1_desc Description
*
* An interface that may be implemented by a wl_surface, for surfaces that
* are designed to be rendered as a layer of a stacked desktop-like
* environment.
*
* Layer surface state (size, anchor, exclusive zone, margin, interactivity)
* is double-buffered, and will be applied at the time wl_surface.commit of
* the corresponding wl_surface is called.
* @section page_iface_zwlr_layer_surface_v1_api API
* See @ref iface_zwlr_layer_surface_v1.
*/
/**
* @defgroup iface_zwlr_layer_surface_v1 The zwlr_layer_surface_v1 interface
*
* An interface that may be implemented by a wl_surface, for surfaces that
* are designed to be rendered as a layer of a stacked desktop-like
* environment.
*
* Layer surface state (size, anchor, exclusive zone, margin, interactivity)
* is double-buffered, and will be applied at the time wl_surface.commit of
* the corresponding wl_surface is called.
*/
extern const struct wl_interface zwlr_layer_surface_v1_interface;
#ifndef ZWLR_LAYER_SHELL_V1_ERROR_ENUM
#define ZWLR_LAYER_SHELL_V1_ERROR_ENUM
enum zwlr_layer_shell_v1_error {
/**
* wl_surface has another role
*/
ZWLR_LAYER_SHELL_V1_ERROR_ROLE = 0,
/**
* layer value is invalid
*/
ZWLR_LAYER_SHELL_V1_ERROR_INVALID_LAYER = 1,
/**
* wl_surface has a buffer attached or committed
*/
ZWLR_LAYER_SHELL_V1_ERROR_ALREADY_CONSTRUCTED = 2,
};
#endif /* ZWLR_LAYER_SHELL_V1_ERROR_ENUM */
#ifndef ZWLR_LAYER_SHELL_V1_LAYER_ENUM
#define ZWLR_LAYER_SHELL_V1_LAYER_ENUM
/**
* @ingroup iface_zwlr_layer_shell_v1
* available layers for surfaces
*
* These values indicate which layers a surface can be rendered in. They
* are ordered by z depth, bottom-most first. Traditional shell surfaces
* will typically be rendered between the bottom and top layers.
* Fullscreen shell surfaces are typically rendered at the top layer.
* Multiple surfaces can share a single layer, and ordering within a
* single layer is undefined.
*/
enum zwlr_layer_shell_v1_layer {
ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND = 0,
ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM = 1,
ZWLR_LAYER_SHELL_V1_LAYER_TOP = 2,
ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY = 3,
};
#endif /* ZWLR_LAYER_SHELL_V1_LAYER_ENUM */
#define ZWLR_LAYER_SHELL_V1_GET_LAYER_SURFACE 0
/**
* @ingroup iface_zwlr_layer_shell_v1
*/
#define ZWLR_LAYER_SHELL_V1_GET_LAYER_SURFACE_SINCE_VERSION 1
/** @ingroup iface_zwlr_layer_shell_v1 */
static inline void
zwlr_layer_shell_v1_set_user_data(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zwlr_layer_shell_v1, user_data);
}
/** @ingroup iface_zwlr_layer_shell_v1 */
static inline void *
zwlr_layer_shell_v1_get_user_data(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1)
{
return wl_proxy_get_user_data((struct wl_proxy *) zwlr_layer_shell_v1);
}
static inline uint32_t
zwlr_layer_shell_v1_get_version(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1)
{
return wl_proxy_get_version((struct wl_proxy *) zwlr_layer_shell_v1);
}
/** @ingroup iface_zwlr_layer_shell_v1 */
static inline void
zwlr_layer_shell_v1_destroy(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1)
{
wl_proxy_destroy((struct wl_proxy *) zwlr_layer_shell_v1);
}
/**
* @ingroup iface_zwlr_layer_shell_v1
*
* Create a layer surface for an existing surface. This assigns the role of
* layer_surface, or raises a protocol error if another role is already
* assigned.
*
* Creating a layer surface from a wl_surface which has a buffer attached
* or committed is a client error, and any attempts by a client to attach
* or manipulate a buffer prior to the first layer_surface.configure call
* must also be treated as errors.
*
* You may pass NULL for output to allow the compositor to decide which
* output to use. Generally this will be the one that the user most
* recently interacted with.
*
* Clients can specify a namespace that defines the purpose of the layer
* surface.
*/
static inline struct zwlr_layer_surface_v1 *
zwlr_layer_shell_v1_get_layer_surface(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1, struct wl_surface *surface, struct wl_output *output, uint32_t layer, const char *namespace)
{
struct wl_proxy *id;
id = wl_proxy_marshal_constructor((struct wl_proxy *) zwlr_layer_shell_v1,
ZWLR_LAYER_SHELL_V1_GET_LAYER_SURFACE, &zwlr_layer_surface_v1_interface, NULL, surface, output, layer, namespace);
return (struct zwlr_layer_surface_v1 *) id;
}
#ifndef ZWLR_LAYER_SURFACE_V1_ERROR_ENUM
#define ZWLR_LAYER_SURFACE_V1_ERROR_ENUM
enum zwlr_layer_surface_v1_error {
/**
* provided surface state is invalid
*/
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SURFACE_STATE = 0,
/**
* size is invalid
*/
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SIZE = 1,
/**
* anchor bitfield is invalid
*/
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_ANCHOR = 2,
};
#endif /* ZWLR_LAYER_SURFACE_V1_ERROR_ENUM */
#ifndef ZWLR_LAYER_SURFACE_V1_ANCHOR_ENUM
#define ZWLR_LAYER_SURFACE_V1_ANCHOR_ENUM
enum zwlr_layer_surface_v1_anchor {
/**
* the top edge of the anchor rectangle
*/
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP = 1,
/**
* the bottom edge of the anchor rectangle
*/
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM = 2,
/**
* the left edge of the anchor rectangle
*/
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT = 4,
/**
* the right edge of the anchor rectangle
*/
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT = 8,
};
#endif /* ZWLR_LAYER_SURFACE_V1_ANCHOR_ENUM */
/**
* @ingroup iface_zwlr_layer_surface_v1
* @struct zwlr_layer_surface_v1_listener
*/
struct zwlr_layer_surface_v1_listener {
/**
* suggest a surface change
*
* The configure event asks the client to resize its surface.
*
* Clients should arrange their surface for the new states, and
* then send an ack_configure request with the serial sent in this
* configure event at some point before committing the new surface.
*
* The client is free to dismiss all but the last configure event
* it received.
*
* The width and height arguments specify the size of the window in
* surface-local coordinates.
*
* The size is a hint, in the sense that the client is free to
* ignore it if it doesn't resize, pick a smaller size (to satisfy
* aspect ratio or resize in steps of NxM pixels). If the client
* picks a smaller size and is anchored to two opposite anchors
* (e.g. 'top' and 'bottom'), the surface will be centered on this
* axis.
*
* If the width or height arguments are zero, it means the client
* should decide its own window dimension.
*/
void (*configure)(void *data,
struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1,
uint32_t serial,
uint32_t width,
uint32_t height);
/**
* surface should be closed
*
* The closed event is sent by the compositor when the surface
* will no longer be shown. The output may have been destroyed or
* the user may have asked for it to be removed. Further changes to
* the surface will be ignored. The client should destroy the
* resource after receiving this event, and create a new surface if
* they so choose.
*/
void (*closed)(void *data,
struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1);
};
/**
* @ingroup iface_zwlr_layer_surface_v1
*/
static inline int
zwlr_layer_surface_v1_add_listener(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1,
const struct zwlr_layer_surface_v1_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) zwlr_layer_surface_v1,
(void (**)(void)) listener, data);
}
#define ZWLR_LAYER_SURFACE_V1_SET_SIZE 0
#define ZWLR_LAYER_SURFACE_V1_SET_ANCHOR 1
#define ZWLR_LAYER_SURFACE_V1_SET_EXCLUSIVE_ZONE 2
#define ZWLR_LAYER_SURFACE_V1_SET_MARGIN 3
#define ZWLR_LAYER_SURFACE_V1_SET_KEYBOARD_INTERACTIVITY 4
#define ZWLR_LAYER_SURFACE_V1_GET_POPUP 5
#define ZWLR_LAYER_SURFACE_V1_ACK_CONFIGURE 6
#define ZWLR_LAYER_SURFACE_V1_DESTROY 7
/**
* @ingroup iface_zwlr_layer_surface_v1
*/
#define ZWLR_LAYER_SURFACE_V1_CONFIGURE_SINCE_VERSION 1
/**
* @ingroup iface_zwlr_layer_surface_v1
*/
#define ZWLR_LAYER_SURFACE_V1_CLOSED_SINCE_VERSION 1
/**
* @ingroup iface_zwlr_layer_surface_v1
*/
#define ZWLR_LAYER_SURFACE_V1_SET_SIZE_SINCE_VERSION 1
/**
* @ingroup iface_zwlr_layer_surface_v1
*/
#define ZWLR_LAYER_SURFACE_V1_SET_ANCHOR_SINCE_VERSION 1
/**
* @ingroup iface_zwlr_layer_surface_v1
*/
#define ZWLR_LAYER_SURFACE_V1_SET_EXCLUSIVE_ZONE_SINCE_VERSION 1
/**
* @ingroup iface_zwlr_layer_surface_v1
*/
#define ZWLR_LAYER_SURFACE_V1_SET_MARGIN_SINCE_VERSION 1
/**
* @ingroup iface_zwlr_layer_surface_v1
*/
#define ZWLR_LAYER_SURFACE_V1_SET_KEYBOARD_INTERACTIVITY_SINCE_VERSION 1
/**
* @ingroup iface_zwlr_layer_surface_v1
*/
#define ZWLR_LAYER_SURFACE_V1_GET_POPUP_SINCE_VERSION 1
/**
* @ingroup iface_zwlr_layer_surface_v1
*/
#define ZWLR_LAYER_SURFACE_V1_ACK_CONFIGURE_SINCE_VERSION 1
/**
* @ingroup iface_zwlr_layer_surface_v1
*/
#define ZWLR_LAYER_SURFACE_V1_DESTROY_SINCE_VERSION 1
/** @ingroup iface_zwlr_layer_surface_v1 */
static inline void
zwlr_layer_surface_v1_set_user_data(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zwlr_layer_surface_v1, user_data);
}
/** @ingroup iface_zwlr_layer_surface_v1 */
static inline void *
zwlr_layer_surface_v1_get_user_data(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1)
{
return wl_proxy_get_user_data((struct wl_proxy *) zwlr_layer_surface_v1);
}
static inline uint32_t
zwlr_layer_surface_v1_get_version(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1)
{
return wl_proxy_get_version((struct wl_proxy *) zwlr_layer_surface_v1);
}
/**
* @ingroup iface_zwlr_layer_surface_v1
*
* Sets the size of the surface in surface-local coordinates. The
* compositor will display the surface centered with respect to its
* anchors.
*
* If you pass 0 for either value, the compositor will assign it and
* inform you of the assignment in the configure event. You must set your
* anchor to opposite edges in the dimensions you omit; not doing so is a
* protocol error. Both values are 0 by default.
*
* Size is double-buffered, see wl_surface.commit.
*/
static inline void
zwlr_layer_surface_v1_set_size(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t width, uint32_t height)
{
wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1,
ZWLR_LAYER_SURFACE_V1_SET_SIZE, width, height);
}
/**
* @ingroup iface_zwlr_layer_surface_v1
*
* Requests that the compositor anchor the surface to the specified edges
* and corners. If two orthoginal edges are specified (e.g. 'top' and
* 'left'), then the anchor point will be the intersection of the edges
* (e.g. the top left corner of the output); otherwise the anchor point
* will be centered on that edge, or in the center if none is specified.
*
* Anchor is double-buffered, see wl_surface.commit.
*/
static inline void
zwlr_layer_surface_v1_set_anchor(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t anchor)
{
wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1,
ZWLR_LAYER_SURFACE_V1_SET_ANCHOR, anchor);
}
/**
* @ingroup iface_zwlr_layer_surface_v1
*
* Requests that the compositor avoids occluding an area of the surface
* with other surfaces. The compositor's use of this information is
* implementation-dependent - do not assume that this region will not
* actually be occluded.
*
* A positive value is only meaningful if the surface is anchored to an
* edge, rather than a corner. The zone is the number of surface-local
* coordinates from the edge that are considered exclusive.
*
* Surfaces that do not wish to have an exclusive zone may instead specify
* how they should interact with surfaces that do. If set to zero, the
* surface indicates that it would like to be moved to avoid occluding
* surfaces with a positive excluzive zone. If set to -1, the surface
* indicates that it would not like to be moved to accomodate for other
* surfaces, and the compositor should extend it all the way to the edges
* it is anchored to.
*
* For example, a panel might set its exclusive zone to 10, so that
* maximized shell surfaces are not shown on top of it. A notification
* might set its exclusive zone to 0, so that it is moved to avoid
* occluding the panel, but shell surfaces are shown underneath it. A
* wallpaper or lock screen might set their exclusive zone to -1, so that
* they stretch below or over the panel.
*
* The default value is 0.
*
* Exclusive zone is double-buffered, see wl_surface.commit.
*/
static inline void
zwlr_layer_surface_v1_set_exclusive_zone(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, int32_t zone)
{
wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1,
ZWLR_LAYER_SURFACE_V1_SET_EXCLUSIVE_ZONE, zone);
}
/**
* @ingroup iface_zwlr_layer_surface_v1
*
* Requests that the surface be placed some distance away from the anchor
* point on the output, in surface-local coordinates. Setting this value
* for edges you are not anchored to has no effect.
*
* The exclusive zone includes the margin.
*
* Margin is double-buffered, see wl_surface.commit.
*/
static inline void
zwlr_layer_surface_v1_set_margin(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, int32_t top, int32_t right, int32_t bottom, int32_t left)
{
wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1,
ZWLR_LAYER_SURFACE_V1_SET_MARGIN, top, right, bottom, left);
}
/**
* @ingroup iface_zwlr_layer_surface_v1
*
* Set to 1 to request that the seat send keyboard events to this layer
* surface. For layers below the shell surface layer, the seat will use
* normal focus semantics. For layers above the shell surface layers, the
* seat will always give exclusive keyboard focus to the top-most layer
* which has keyboard interactivity set to true.
*
* Layer surfaces receive pointer, touch, and tablet events normally. If
* you do not want to receive them, set the input region on your surface
* to an empty region.
*
* Events is double-buffered, see wl_surface.commit.
*/
static inline void
zwlr_layer_surface_v1_set_keyboard_interactivity(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t keyboard_interactivity)
{
wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1,
ZWLR_LAYER_SURFACE_V1_SET_KEYBOARD_INTERACTIVITY, keyboard_interactivity);
}
/**
* @ingroup iface_zwlr_layer_surface_v1
*
* This assigns an xdg_popup's parent to this layer_surface. This popup
* should have been created via xdg_surface::get_popup with the parent set
* to NULL, and this request must be invoked before committing the popup's
* initial state.
*
* See the documentation of xdg_popup for more details about what an
* xdg_popup is and how it is used.
*/
static inline void
zwlr_layer_surface_v1_get_popup(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, struct xdg_popup *popup)
{
wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1,
ZWLR_LAYER_SURFACE_V1_GET_POPUP, popup);
}
/**
* @ingroup iface_zwlr_layer_surface_v1
*
* When a configure event is received, if a client commits the
* surface in response to the configure event, then the client
* must make an ack_configure request sometime before the commit
* request, passing along the serial of the configure event.
*
* If the client receives multiple configure events before it
* can respond to one, it only has to ack the last configure event.
*
* A client is not required to commit immediately after sending
* an ack_configure request - it may even ack_configure several times
* before its next surface commit.
*
* A client may send multiple ack_configure requests before committing, but
* only the last request sent before a commit indicates which configure
* event the client really is responding to.
*/
static inline void
zwlr_layer_surface_v1_ack_configure(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial)
{
wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1,
ZWLR_LAYER_SURFACE_V1_ACK_CONFIGURE, serial);
}
/**
* @ingroup iface_zwlr_layer_surface_v1
*
* This request destroys the layer surface.
*/
static inline void
zwlr_layer_surface_v1_destroy(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1)
{
wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1,
ZWLR_LAYER_SURFACE_V1_DESTROY);
wl_proxy_destroy((struct wl_proxy *) zwlr_layer_surface_v1);
}
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,45 +0,0 @@
/*
* Copyright (C) 2019-2020 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WAIFU_H
#define WAIFU_H
#include <wofi_api.h>
#include <stdbool.h>
#include <map.h>
#include <gtk/gtk.h>
struct widget {
size_t action_count;
char* mode, **text, *search_text, **actions;
struct widget_builder* builder;
};
struct mode {
void (*mode_exec)(const gchar* cmd);
struct widget* (*mode_get_widget)(void);
char* name, *dso;
struct wl_list link;
};
void wofi_init(struct map* config);
void wofi_load_css(bool nyan);
#endif

View File

@ -1,63 +0,0 @@
/*
* Copyright (C) 2020-2024 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WOFI_API_H
#define WOFI_API_H
#include <stddef.h>
#include <stdbool.h>
#include <wayland-client.h>
struct cache_line {
char* line;
struct wl_list link;
};
struct mode;
char* wofi_parse_image_escapes(const char* text);
void wofi_write_cache(struct mode* mode, const char* cmd);
void wofi_remove_cache(struct mode* mode, const char* cmd);
struct wl_list* wofi_read_cache(struct mode* mode);
struct widget* wofi_create_widget(struct mode* mode, char* text[], char* search_text, char* actions[], size_t action_count);
void wofi_insert_widgets(struct mode* mode);
char* wofi_get_dso_path(struct mode* mode);
bool wofi_allow_images(void);
bool wofi_allow_markup(void);
uint64_t wofi_get_image_size(void);
uint64_t wofi_get_window_scale(void);
bool wofi_mod_shift(void);
bool wofi_mod_control(void);
void wofi_term_run(const char* cmd);
void wofi_exit(int status);
#endif

View File

@ -1,392 +0,0 @@
/* Generated by wayland-scanner 1.16.0 */
#ifndef XDG_OUTPUT_UNSTABLE_V1_CLIENT_PROTOCOL_H
#define XDG_OUTPUT_UNSTABLE_V1_CLIENT_PROTOCOL_H
#include <stdint.h>
#include <stddef.h>
#include "wayland-client.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @page page_xdg_output_unstable_v1 The xdg_output_unstable_v1 protocol
* Protocol to describe output regions
*
* @section page_desc_xdg_output_unstable_v1 Description
*
* This protocol aims at describing outputs in a way which is more in line
* with the concept of an output on desktop oriented systems.
*
* Some information are more specific to the concept of an output for
* a desktop oriented system and may not make sense in other applications,
* such as IVI systems for example.
*
* Typically, the global compositor space on a desktop system is made of
* a contiguous or overlapping set of rectangular regions.
*
* Some of the information provided in this protocol might be identical
* to their counterparts already available from wl_output, in which case
* the information provided by this protocol should be preferred to their
* equivalent in wl_output. The goal is to move the desktop specific
* concepts (such as output location within the global compositor space,
* the connector name and types, etc.) out of the core wl_output protocol.
*
* Warning! The protocol described in this file is experimental and
* backward incompatible changes may be made. Backward compatible
* changes may be added together with the corresponding interface
* version bump.
* Backward incompatible changes are done by bumping the version
* number in the protocol and interface names and resetting the
* interface version. Once the protocol is to be declared stable,
* the 'z' prefix and the version number in the protocol and
* interface names are removed and the interface version number is
* reset.
*
* @section page_ifaces_xdg_output_unstable_v1 Interfaces
* - @subpage page_iface_zxdg_output_manager_v1 - manage xdg_output objects
* - @subpage page_iface_zxdg_output_v1 - compositor logical output region
* @section page_copyright_xdg_output_unstable_v1 Copyright
* <pre>
*
* Copyright © 2017 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* </pre>
*/
struct wl_output;
struct zxdg_output_manager_v1;
struct zxdg_output_v1;
/**
* @page page_iface_zxdg_output_manager_v1 zxdg_output_manager_v1
* @section page_iface_zxdg_output_manager_v1_desc Description
*
* A global factory interface for xdg_output objects.
* @section page_iface_zxdg_output_manager_v1_api API
* See @ref iface_zxdg_output_manager_v1.
*/
/**
* @defgroup iface_zxdg_output_manager_v1 The zxdg_output_manager_v1 interface
*
* A global factory interface for xdg_output objects.
*/
extern const struct wl_interface zxdg_output_manager_v1_interface;
/**
* @page page_iface_zxdg_output_v1 zxdg_output_v1
* @section page_iface_zxdg_output_v1_desc Description
*
* An xdg_output describes part of the compositor geometry.
*
* This typically corresponds to a monitor that displays part of the
* compositor space.
* @section page_iface_zxdg_output_v1_api API
* See @ref iface_zxdg_output_v1.
*/
/**
* @defgroup iface_zxdg_output_v1 The zxdg_output_v1 interface
*
* An xdg_output describes part of the compositor geometry.
*
* This typically corresponds to a monitor that displays part of the
* compositor space.
*/
extern const struct wl_interface zxdg_output_v1_interface;
#define ZXDG_OUTPUT_MANAGER_V1_DESTROY 0
#define ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT 1
/**
* @ingroup iface_zxdg_output_manager_v1
*/
#define ZXDG_OUTPUT_MANAGER_V1_DESTROY_SINCE_VERSION 1
/**
* @ingroup iface_zxdg_output_manager_v1
*/
#define ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT_SINCE_VERSION 1
/** @ingroup iface_zxdg_output_manager_v1 */
static inline void
zxdg_output_manager_v1_set_user_data(struct zxdg_output_manager_v1 *zxdg_output_manager_v1, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zxdg_output_manager_v1, user_data);
}
/** @ingroup iface_zxdg_output_manager_v1 */
static inline void *
zxdg_output_manager_v1_get_user_data(struct zxdg_output_manager_v1 *zxdg_output_manager_v1)
{
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_output_manager_v1);
}
static inline uint32_t
zxdg_output_manager_v1_get_version(struct zxdg_output_manager_v1 *zxdg_output_manager_v1)
{
return wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1);
}
/**
* @ingroup iface_zxdg_output_manager_v1
*
* Using this request a client can tell the server that it is not
* going to use the xdg_output_manager object anymore.
*
* Any objects already created through this instance are not affected.
*/
static inline void
zxdg_output_manager_v1_destroy(struct zxdg_output_manager_v1 *zxdg_output_manager_v1)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_output_manager_v1,
ZXDG_OUTPUT_MANAGER_V1_DESTROY);
wl_proxy_destroy((struct wl_proxy *) zxdg_output_manager_v1);
}
/**
* @ingroup iface_zxdg_output_manager_v1
*
* This creates a new xdg_output object for the given wl_output.
*/
static inline struct zxdg_output_v1 *
zxdg_output_manager_v1_get_xdg_output(struct zxdg_output_manager_v1 *zxdg_output_manager_v1, struct wl_output *output)
{
struct wl_proxy *id;
id = wl_proxy_marshal_constructor((struct wl_proxy *) zxdg_output_manager_v1,
ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT, &zxdg_output_v1_interface, NULL, output);
return (struct zxdg_output_v1 *) id;
}
/**
* @ingroup iface_zxdg_output_v1
* @struct zxdg_output_v1_listener
*/
struct zxdg_output_v1_listener {
/**
* position of the output within the global compositor space
*
* The position event describes the location of the wl_output
* within the global compositor space.
*
* The logical_position event is sent after creating an xdg_output
* (see xdg_output_manager.get_xdg_output) and whenever the
* location of the output changes within the global compositor
* space.
* @param x x position within the global compositor space
* @param y y position within the global compositor space
*/
void (*logical_position)(void *data,
struct zxdg_output_v1 *zxdg_output_v1,
int32_t x,
int32_t y);
/**
* size of the output in the global compositor space
*
* The logical_size event describes the size of the output in the
* global compositor space.
*
* For example, a surface without any buffer scale, transformation
* nor rotation set, with the size matching the logical_size will
* have the same size as the corresponding output when displayed.
*
* Most regular Wayland clients should not pay attention to the
* logical size and would rather rely on xdg_shell interfaces.
*
* Some clients such as Xwayland, however, need this to configure
* their surfaces in the global compositor space as the compositor
* may apply a different scale from what is advertised by the
* output scaling property (to achieve fractional scaling, for
* example).
*
* For example, for a wl_output mode 3840×2160 and a scale factor
* 2:
*
* - A compositor not scaling the surface buffers will advertise a
* logical size of 3840×2160,
*
* - A compositor automatically scaling the surface buffers will
* advertise a logical size of 1920×1080,
*
* - A compositor using a fractional scale of 1.5 will advertise a
* logical size to 2560×1620.
*
* For example, for a wl_output mode 1920×1080 and a 90 degree
* rotation, the compositor will advertise a logical size of
* 1080x1920.
*
* The logical_size event is sent after creating an xdg_output (see
* xdg_output_manager.get_xdg_output) and whenever the logical size
* of the output changes, either as a result of a change in the
* applied scale or because of a change in the corresponding output
* mode(see wl_output.mode) or transform (see wl_output.transform).
* @param width width in global compositor space
* @param height height in global compositor space
*/
void (*logical_size)(void *data,
struct zxdg_output_v1 *zxdg_output_v1,
int32_t width,
int32_t height);
/**
* all information about the output have been sent
*
* This event is sent after all other properties of an xdg_output
* have been sent.
*
* This allows changes to the xdg_output properties to be seen as
* atomic, even if they happen via multiple events.
*/
void (*done)(void *data,
struct zxdg_output_v1 *zxdg_output_v1);
/**
* name of this output
*
* Many compositors will assign names to their outputs, show them
* to the user, allow them to be configured by name, etc. The
* client may wish to know this name as well to offer the user
* similar behaviors.
*
* The naming convention is compositor defined, but limited to
* alphanumeric characters and dashes (-). Each name is unique
* among all wl_output globals, but if a wl_output global is
* destroyed the same name may be reused later. The names will also
* remain consistent across sessions with the same hardware and
* software configuration.
*
* Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc.
* However, do not assume that the name is a reflection of an
* underlying DRM connector, X11 connection, etc.
*
* The name event is sent after creating an xdg_output (see
* xdg_output_manager.get_xdg_output). This event is only sent once
* per xdg_output, and the name does not change over the lifetime
* of the wl_output global.
* @param name output name
* @since 2
*/
void (*name)(void *data,
struct zxdg_output_v1 *zxdg_output_v1,
const char *name);
/**
* human-readable description of this output
*
* Many compositors can produce human-readable descriptions of
* their outputs. The client may wish to know this description as
* well, to communicate the user for various purposes.
*
* The description is a UTF-8 string with no convention defined for
* its contents. Examples might include 'Foocorp 11" Display' or
* 'Virtual X11 output via :1'.
*
* The description event is sent after creating an xdg_output (see
* xdg_output_manager.get_xdg_output). This event is only sent once
* per xdg_output, and the description does not change over the
* lifetime of the wl_output global. The description is optional,
* and may not be sent at all.
* @param description output description
* @since 2
*/
void (*description)(void *data,
struct zxdg_output_v1 *zxdg_output_v1,
const char *description);
};
/**
* @ingroup iface_zxdg_output_v1
*/
static inline int
zxdg_output_v1_add_listener(struct zxdg_output_v1 *zxdg_output_v1,
const struct zxdg_output_v1_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) zxdg_output_v1,
(void (**)(void)) listener, data);
}
#define ZXDG_OUTPUT_V1_DESTROY 0
/**
* @ingroup iface_zxdg_output_v1
*/
#define ZXDG_OUTPUT_V1_LOGICAL_POSITION_SINCE_VERSION 1
/**
* @ingroup iface_zxdg_output_v1
*/
#define ZXDG_OUTPUT_V1_LOGICAL_SIZE_SINCE_VERSION 1
/**
* @ingroup iface_zxdg_output_v1
*/
#define ZXDG_OUTPUT_V1_DONE_SINCE_VERSION 1
/**
* @ingroup iface_zxdg_output_v1
*/
#define ZXDG_OUTPUT_V1_NAME_SINCE_VERSION 2
/**
* @ingroup iface_zxdg_output_v1
*/
#define ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION 2
/**
* @ingroup iface_zxdg_output_v1
*/
#define ZXDG_OUTPUT_V1_DESTROY_SINCE_VERSION 1
/** @ingroup iface_zxdg_output_v1 */
static inline void
zxdg_output_v1_set_user_data(struct zxdg_output_v1 *zxdg_output_v1, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) zxdg_output_v1, user_data);
}
/** @ingroup iface_zxdg_output_v1 */
static inline void *
zxdg_output_v1_get_user_data(struct zxdg_output_v1 *zxdg_output_v1)
{
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_output_v1);
}
static inline uint32_t
zxdg_output_v1_get_version(struct zxdg_output_v1 *zxdg_output_v1)
{
return wl_proxy_get_version((struct wl_proxy *) zxdg_output_v1);
}
/**
* @ingroup iface_zxdg_output_v1
*
* Using this request a client can tell the server that it is not
* going to use the xdg_output object anymore.
*/
static inline void
zxdg_output_v1_destroy(struct zxdg_output_v1 *zxdg_output_v1)
{
wl_proxy_marshal((struct wl_proxy *) zxdg_output_v1,
ZXDG_OUTPUT_V1_DESTROY);
wl_proxy_destroy((struct wl_proxy *) zxdg_output_v1);
}
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,116 +0,0 @@
.TH wofi\-api 3
.SH NAME
wofi \- API functions and documentation
.SH DESCRIPTION
The functions documented here are used for interacting with wofi. They are defined in wofi_api.h.
.SH STRUCTURES
struct cache_line {
.RS 4
char* line;
.br
struct wl_list link;
.RE
};
.SH API FUNCTIONS
The following functions are used to interact with wofi.
.TP
.B char* wofi_parse_image_escapes(const char* text)
This function takes in text containing image escapes and pango markup and will return the plain text with all of that stripped. The string returned is newly allocated and should be freed by the caller when they are done with it.
.B const char* text
\- The input text containing image escapes and pango markup.
.TP
.B void wofi_write_cache(struct mode* mode, const char* cmd)
Writes an entry to the cache file.
.B struct mode* mode
\- The \fBstruct mode*\fR given to your mode's \fBinit()\fR function.
.B const char* cmd
\- The entry to write to the cache file. If this entry already exists the number of times it has been written will be incremented.
.TP
.B void wofi_remove_cache(struct mode* mode, const char* cmd)
Removes an entry from the cache file.
.B struct mode* mode
\- The \fBstruct mode*\fR given to your mode's \fBinit()\fR function.
.B const char* cmd
\- The entry to remove from the cache file. This does NOT decrement the number of times written, it fully removes the entry.
.TP
.B struct wl_list* wofi_read_cache(struct mode* mode)
Reads the cache and returns a \fBstruct wl_list*\fR containing the entires. The list is made up of \fBstruct cache_line*\fR entries. The wayland documentation should be referred to for the usage of a wl_list.
.B struct mode* mode
\- The \fBstruct mode*\fR given to your mode's \fBinit()\fR function.
.TP
.B struct widget* wofi_create_widget(struct mode* mode, char* text[], char* search_text, char* actions[], size_t action_count)
Creates a widget from the specified information. This widget should be returned by the mode's \fBget_widget()\fR function in order to be displayed.
.B struct mode* mode
\- The \fBstruct mode*\fR given to your mode's \fBinit()\fR function.
.B char* text[]
\- The array of text to display on the entry in wofi. Each element in the array represents the text for 1 action. The array should only be larger than 1 if you're creating a multi\-action entry. Multi\-action entries need to provide 1 string for every action the entry has.
.B char* search_text
\- The text which the user can search for to find this widget.
.B char* actions[]
\- The array of actions for the entry. An action is the text given to a mode's \fBexec()\fR function when the user selects an entry. Multi\-action entries need to provide 1 action string for every action the entry has.
.B size_t action_count
\- The number of actions the entry will have.
.TP
.B void wofi_insert_widgets(struct mode* mode)
This will requery the mode for more widgets.
.B struct mode* mode
\- The \fBstruct mode*\fR given to your mode's \fBinit()\fR function.
.TP
.B char* wofi_get_dso_path(struct mode* mode)
Returns the path to this mode's DSO if it's an external mode, returns NULL otherwise.
.B struct mode* mode
\- The \fBstruct mode*\fR given to your mode's \fBinit()\fR function.
.TP
.B bool wofi_allow_images(void)
Returns true if the user enabled images, false otherwise.
.TP
.B bool wofi_allow_markup(void)
Returns true if the user enabled pango markup, false otherwise.
.TP
.B uint64_t wofi_get_image_size(void)
Returns the user specified image size, 32 by default. Wofi will scale images for you, this is just informational and is not required but can be helpful if multiple sizes are available.
.TP
.B bool wofi_mod_shift(void)
Returns true if the user was holding shift when selecting an entry, false otherwise.
.TP
.B bool wofi_mod_control(void)
Returns true if the user was holding control when selecting an entry, false otherwise.
.TP
.B void wofi_term_run(const char* cmd)
Runs the provided cmd in a terminal emulator. The following order is used for picking a terminal emulator: The user specified terminal, kitty, alacritty, wezterm, foot, termite, gnome\-terminal, weston\-terminal. If none of these can be found execution will fail.
.B const char* cmd
\- The command to run, this is invoked by doing \fBterm \-\- cmd\fR.
.TP
.B void wofi_exit(void)
This function is how you should call to exit wofi. It checks the status given and only sets a custom exit code if you pass EXIT_SUCCESS. If you call the libc exit() function then the custom exit code will always be used even if an error should be reported

View File

@ -1,61 +0,0 @@
.TH wofi\-config 3
.SH NAME
wofi \- Config functions and documentation
.SH DESCRIPTION
The functions documented here are used for manipulating maps that represent config entries. They are defined in config.h.
.SH CONFIG FUNCTIONS
The following functions are used to work with configs.
.TP
.B void config_put(struct map* map, char* line)
Parses a single config line and inserts the result into the map
.B struct map* map
\- The map to insert into.
.B char* line
\- The config line to insert. Should be in the format of \fBkey=\fIvalue\fR.
.TP
.B void config_load(struct map* map, const char* config)
Loads a config file into the given map
.B struct map* map
\- The map to load the config into.
.B const char* config
\- The path to a config file. Should contain lines with the format of \fBkey=\fIvalue\fR.
.TP
.B char* config_get(struct map* config, const char* key, char* def_opt)
Gets a config entry, if the entry is not set then it returns \fBdef_opt\fR.
.B struct map* config
\- The map to get the value from.
.B const char* key
\- The key to lookup.
.B char* def_opt
\- The default value to be returned if the key does not exist.
.TP
.B int config_get_mnemonic(struct map* config, const char* key, char* def_opt, int num_choices, ...)
Gets an enum value from the config. If the value is not set then it returns \fBdef_opt\fR.
.B struct map* config
\- The map to get the value from.
.B const char* key
\- The key to lookup.
.B char* def_opt
\- The default value to be returned if the key does not exist.
.B int num_choices
\- The number of enum options available.
.B varargs
\- The list of enum options available.

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +0,0 @@
.TH wofi\-map 3
.SH NAME
wofi \- Map API functions and documentation
.SH DESCRIPTION
The functions documented here are used for interacting with wofi's config and map. They are defined in map.h.
.SH MAP FUNCTIONS
The following functions are used to interact with a \fBstruct map*\fR
.TP
.B struct map* map_init(void)
Allocates and returns a new string map. String maps only support string values.
.TP
.B struct map* map_init_void(void)
Allocates and returns a new void map. A void map supports values of any type.
.TP
.B void map_free(struct map* map)
Frees the provided map and all it's keys. Values are only freed if it is a string map.
.TP
.B bool map_put(struct map* map, const char* key, char* value)
Returns true if the given map is a string map, otherwise returns false and prints a message to stderr.
.B struct map* map
\- The map to insert into.
.B const char* key
\- The key to store the value under. This key is given to \fBstrdup()\fR before being saved and will be freed when running \fBmap_free()\fR.
.B char* value
\- The value to store. This value is given to \fBstrdup()\fR before being saved and will be freed when running \fBmap_free()\fR. If the value is \fBNULL\fR it will not be given to \fBstrdup()\fR.
.TP
.B bool map_put_void(struct map* map, const char* key, void* value)
Returns true if the given map is a void map, otherwise returns false and prints a message to stderr.
.B struct map* map
\- The map to insert into.
.B const char* key
\- The key to store the value under. This key is given to \fBstrdup()\fR before being saved and will be freed when running \fBmap_free()\fR.
.B void* value
\- The value to store. This pointer is stored in the map, it is on the caller to free this and it will not be freed when running \fBmap_free()\fR.
.TP
.B void* map_get(struct map* map, const char* key)
Returns the value stored under \fBkey\fR or \fBNULL\fR if no key exists. \fBNULL\fR can also be returned if it was stored there with \fBmap_put()\fR or \fBmap_put_void()\fR.
.B struct map* map
\- The map to get the value from.
.B const char* key
\- The key to lookup.
.TP
.B bool map_contains(struct map* map, const char* key)
Returns true if the key exists, false otherwise. This is implemented as a \fBvalue != NULL\fR check so a \fBNULL\fR value is considered to not exist.
.B struct map* map
\- The map to check against.
.B const char* key
\- The key to check for.
.TP
.B size_t map_size(struct map* map)
Returns the number of entries in this map.
.B struct map* map
\- The map to get the size of.

View File

@ -1,63 +0,0 @@
.TH wofi\-utils 3
.SH NAME
wofi \- Utility functions and documentation
.SH DESCRIPTION
The functions documented here are general utility functions. They are defined in utils.h.
.SH UTILITY FUNCTIONS
The following functions are general convenience functions.
.TP
.B time_t utils_get_time_millis(void)
Returns the current unix time in milliseconds.
.TP
.B void utils_sleep_millis(time_t millis)
Sleeps for the specified amount of time.
.B time_t millis
\- The time to sleep for in milliseconds.
.TP
.B char* utils_concat(size_t arg_count, ...)
Concatenates strings together. The returned result is newly allocated and must be freed by the caller when finished using it.
.B size_t arg_count
\- The number of arguments provided
.B varargs
\- The list of strings to be concatenated.
.TP
.B size_t utils_min(size_t n1, size_t n2)
Returns the smaller of the two inputs.
.B size_t n1
\- The first number.
.B size_t n2
\- The second number.
.TP
.B size_t utils_min3(size_t n1, size_t n2, size_t n3)
Returns the smallest of the three inputs.
.B size_t n1
\- The first number.
.B size_t n2
\- The second number.
.B size_t n3
\- The third number.
.TP
.B size_t utils_distance(const char* haystack, const char* needle)
Computes the Levenshtein distance between the two inputs.
.B const char* haystack
\- The string to search in.
.B const char* needle
\- The string to search for.

View File

@ -1,112 +0,0 @@
.TH wofi\-widget\-builder 3
.SH NAME
wofi \- Widget builder API functions
.SH DESCRIPTION
The functions documented here are used for building custom widgets with more power and flexibility than previously allowed. They are defined in wofi_widget_builder_api.h
.TP
.B struct widget_builder* wofi_widget_builder_init(struct mode* mode, size_t actions)
Creates multiple widget builders. The number of builders created is specified by actions and is returned as an array.
.B struct mode* mode
\- The \fBstruct mode*\fR given to your mode's \fBinit()\fR function.
.B size_t actions
\- The number of builders to create
.TP
.B void wofi_widget_builder_set_search_text(struct widget_builder* builder, char* search_text)
Sets the search text for the widget specified by the builder
.B struct widget_builder* builder
\- The builder that contains the widget to set the search text for
.B char* search_text
\- The text to set as the search text
.TP
.B void wofi_widget_builder_set_action(struct widget_builder* builder, char* action)
Sets the action for the widget specified by the builder
.B struct widget_builder* builder
\- The builder that contains the widget to set the action for
.B char* action
\- The text to set as the action
.TP
.B void wofi_widget_builder_insert_text(struct widget_builder* builder, char* text, ...)
Inserts text into the widget specified by the builder
.B struct widget_builder* builder
\- The builder that contains the widget to add the text to
.B char* text
\- The text to add to the widget
.B ...
\- The names of the CSS classes for this text. The class that will be assigned is .mode_name-css_name where mode_name is the name of the mode, i.e. drun etc. This should have a NULL sentinel
.TP
.B void wofi_widget_builder_insert_text_with_list(struct widget_builder* builder, char* text, struct wl_list* classes)
Inserts text into the widget specified by the builder
.B struct widget_builder* builder
\- The builder that contains the widget to add the text to
.B char* text
\- The text to add to the widget
.B struct wl_list* classes
\- The names of the CSS classes for this text. The class that will be assigned is .mode_name-css_name where mode_name is the name of the mode, i.e. drun etc. This list should contain struct css_class nodes.
.TP
.B void wofi_widget_builder_insert_image(struct widget_builder* builder, GdkPixbuf* pixbuf, ...)
Inserts an image into the widget specified by the builder
.B struct widget_builder* builder
\- The builder that contains the widget to add the image to
.B GdkPixbuf* pixbuf
\- The image to add to the widget
.B ...
\- The names of the CSS classes for this image. The class that will be assigned is .mode_name-css_name where mode_name is the name of the mode, i.e. drun etc. This should have a NULL sentinel
.TP
.B void wofi_widget_builder_insert_image_with_list(struct widget_builder* builder, GdkPixbuf* pixbuf, struct wl_list* classes)
Inserts an image into the widget specified by the builder
.B struct widget_builder* builder
\- The builder that contains the widget to add the image to
.B GdkPixbuf* pixbuf
\- The image to add to the widget
.B struct wl_list* classes
\- The names of the CSS classes for this image. The class that will be assigned is .mode_name-css_name where mode_name is the name of the mode, i.e. drun etc. This list should contain struct css_class nodes.
.TP
.B struct widget_builder* wofi_widget_builder_get_idx(struct widget_builder* builder, size_t idx)
Gets the widget_builder at the provided index in the array
.B struct widget_builder* builder
\- The array of builders to get the builder from
.B size_t idx
\- The index in the array to get
.TP
.B struct widget* wofi_widget_builder_get_widget(struct widget_builder* builder)
Constructs a new widget from the specified builder, the widget can be returned by \fBstruct widget* get_widget(void)\fR
.B struct widget_builder* builder
\- The builder to construct a widget for
.TP
.B void wofi_widget_builder_free(struct widget_builder* builder)
Frees the specified builder
.B struct widget_builder* builder
\- The builder to free

View File

@ -1,135 +0,0 @@
.TH wofi 1
.SH NAME
wofi \- A rofi inspired launcher for wlroots compositors
.SH SYNOPSIS
.B wofi
[options]
.SH DESCRIPTION
.B wofi
is a rofi inspired menu program for wlroots compositors such as sway. It is intended to be highly customizable and flexible with the help of CSS styling and a dmenu mode that allows for endless scriptability. Wofi can be run cacheless in dmenu mode automatically by invoking it as dmenu with symlink.
Wofi was designed specifically for wlroots and makes use of the wlr\-layer\-shell protocol. If your compositor does not support this protocol or if you are in a non\-wayland environment then wofi must be run with \fB\-\-normal\-window\fR or it will crash. If you wish to run wofi this way you can also place \fBnormal_window=true\fR in your config file to avoid specifying the option on the command line.
.SH OPTIONS
.TP
.B \-h, \-\-help
Prints the help message and then exits.
.TP
.B \-f, \-\-fork
Forks the menu so the terminal running it can be closed.
.TP
.B \-c, \-\-conf=\fIPATH\fR
Specifies the config file to use.
.TP
.B \-s, \-\-style=\fIPATH\fR
Specifies the CSS file to use as the stylesheet.
.TP
.B \-C, \-\-color=\fIPATH\fR
Specifies the colors file to use.
.TP
.B \-d, \-\-dmenu
Runs wofi in dmenu mode.
.TP
.B \-S, \-\-show=\fIMODE\fR
Specifies the mode to run in. A list of modes can be found in \fBwofi\fR(7).
.TP
.B \-W, \-\-width=\fIWIDTH\fR
Specifies the menu width in pixels or percent of screen size, default is 50%. Pixels are used unless the number ends with a %.
.TP
.B \-H, \-\-height=\fIHEIGHT\fR
Specifies the menu height in pixels or percent of screen size, default is 40%. Pixels are used unless the number ends with a %.
.TP
.B \-p, \-\-prompt=\fIPROMPT\fR
Sets the prompt to be display in the search box, default is the name of the mode.
.TP
.B \-x, \-\-xoffset=\fIOFFSET\fR
Sets the x offset from the location in pixels, default is 0.
.TP
.B \-y, \-\-yoffset=\fIOFFSET\fR
Sets the y offset from the location in pixels, default is 0.
.TP
.B \-n, \-\-normal\-window
Runs wofi in a normal window instead of using wlr\-layer\-shell.
.TP
.B \-I, \-\-allow\-images
Allows image escape sequences to be processed and rendered.
.TP
.B \-m, \-\-allow\-markup
Allows pango markup to be processed and rendered.
.TP
.B \-k, \-\-cache\-file=\fIPATH\fR
Specifies the cache file to load/store cache, default is $XDG_CACHE_HOME/wofi\-<mode name> where <mode name> is the name of the mode, if $XDG_CACHE_HOME is not specified ~/.cache is used.
.TP
.B \-t, \-\-term=\fITERM\fR
Specifies the term to use when running a program in a terminal. This overrides the default terminal run order which is kitty, alacritty, wezterm, foot, termite, gnome\-terminal, weston\-terminal in that order.
.TP
.B \-P, \-\-password \fR[character]
Runs wofi in password mode with an optional password character to use. If no character is specified * is used by default.
.TP
.B \-e, \-\-exec\-search
Activiating a search with enter will execute the search not the first result.
.TP
.B \-b, \-\-hide\-scroll
Hides the scroll bars.
.TP
.B \-M, \-\-matching=\fIMODE\fR
Specifies the matching mode, it can be either contains, multi-contains, or fuzzy, default is contains.
.TP
.B \-i, \-\-insensitive
Enables case insensitive search.
.TP
.B \-q, \-\-parse\-search
Parses out image escapes and pango preventing them from being used for searching.
.TP
.B \-v, \-\-version
Prints the version and then exits.
.TP
.B \-l, \-\-location=\fILOCATION\fR
Specifies the location. See \fBwofi\fR(7) for more information, default is center.
.TP
.B \-a, \-\-no\-actions
Disables multiple actions for modes that support it.
.TP
.B \-D, \-\-define=\fIKEY=VALUE\fR
Sets a config option
.TP
.B \-L, \-\-lines=\fILINES\fR
Specifies the height in number of lines instead of pixels.
.TP
.B \-w, \-\-columns=\fICOLUMNS\fR
Specifies the number of columns to display, default is 1.
.TP
.B \-O, \-\-sort\-order=\fIORDER\fR
Specifies the default sort order. There are currently two orders, default and alphabetical. See \fBwofi\fR(7) for details.
.TP
.B \-G, \-\-gtk\-dark
Instructs wofi to use the dark variant of the current GTK theme, if available.
.TP
.B \-Q, \-\-search
Specifies something to search for immediately on opening
.TP
.B \-o, \-\-monitor
Sets the monitor to open on
.TP
.B \-r, \-\-pre\-display\-cmd
If set, the selectable entry won't be displayed as-is, but will instead be displayed based on the output of this command, which can be anything. Suggested to use with \fB"echo %s | some_cmd"\fR or \fB"some_cmd %s"\fR, as the string gets replaced in a printf-like fashion. This will not affect the output of wofi once a selection has been done, allowing you to display something else than the original output.
.SH CONFIGURATION
Wofi has 3 main files used for configuration. All files are completely optional.
.IP 1. 4
The config file which defaults to $XDG_CONFIG_HOME/wofi/config.
.IP 2. 4
The CSS file which defaults to $XDG_CONFIG_HOME/wofi/style.css.
.IP 3. 4
The colors file which defaults to the pywal cache $XDG_CACHE_HOME/wal/colors.
.P
All 3 of these paths can be manually specified using the respective command line flag. In the case of the last 2 they can additionally be specified in the config file.
In the event $XDG_CONFIG_HOME is not specified it defaults to ~/.config likewise if $XDG_CACHE_HOME is not specified it defaults to ~/.cache.
Information about the formats for these files can be found in
.B wofi\fR(5).

View File

@ -1,54 +0,0 @@
.TH wofi 3
.SH NAME
wofi \- Mode functions and documentation
.SH DESCRIPTION
Wofi provides a C API which can be used for developing 3rd party modes. These modes should be compiled to a shared object which should be placed in $XDG_CONFIG_HOME/wofi/plugins. If $XDG_CONFIG_HOME is not defined then it will default to ~/.config.
It is very important to note that this API is not stable. It's mostly stable however if something comes up that requires a substantial change things will be changed. This shouldn't happen too much but has happened in the past and might in the future.
.SH HEADER FILES
There are 2 header files required in order to use the wofi API, wofi_api.h and map.h. utils.h might be useful to include if you want a few helper functions but it is not required. utils.h will not be documented here as it's outside the scope of the mode API.
.SH MODE FUNCTIONS
The following list of functions are the functions which can be defined inside of your mode which will be called to do setup, and acquire various pieces of information from the mode.
.TP
.B void init(struct mode* mode, struct map* config)
Defining this function is required. This function is called to setup your plugin and provide it with several pointers which are described below.
.B struct mode* mode
\- used to identify your mode, it is passed to a large number of the API functions to identify your mode.
.B struct map* config
\- all of the config options that the user defined for your mode. Information on how to access this can be found in \fBwofi\-map(3)\fR.
.TP
.B void load(struct mode* mode)
Defining this function is optional. This function is called before ALL others and provides your mode pointer as early as possible.
.B struct mode* mode
\- used to identify your mode, it is passed to a large number of the API functions to identify your mode.
.TP
.B const char** get_arg_names(void)
Defining this function is optional. This function is called to get an array of config options which can be set by the user. All of these options have the name of your mode prefixed on the front so if your array is for example \fB{"opt1", "opt2"}\fR the config options defined will be \fBmode-opt1=\fIvalue\fR and \fBmode-opt2=\fIvalue\fR where mode is the name of the shared object.
.TP
.B size_t get_arg_count(void)
Defining this function is optional. This function is called to get the number of arguments returned by \fBget_arg_names(void)\fR.
.TP
.B void exec(const char* cmd)
Defining this function is required. This function is called when the user selects an entry.
.B const char* cmd
\- The action registered to the selected entry. If your mode allows executing searches directly then this will be the search contents if no matching entries exist.
.TP
.B struct widget* get_widget(void)
Defining this function is optional. This function is called to request the next widget to be added. See \fBwofi_create_widget()\fR in \fBwofi\-api(3)\fR on how to obtain a \fBstruct widget*\fR. \fBNULL\fR should be returned to denote no more widgets are available.
.TP
.B bool no_entry(void)
Defining this function is optional. This function is called to find out whether or not this mode supports running searches without any matching entries. The default is false, if you wish to allow your mode to take searches directly you must define this and return true.

View File

@ -1,258 +0,0 @@
.TH wofi 5
.SH NAME
wofi \- configuration file and styling
.SH DESCRIPTION
Wofi's configuration format is very simple, consisting of key value pairs in snake case. The majority of the config options are the command line options, there are however a small handful of options only accessible via wofi's config.
Mode specific options for the built\-in modes are documented in \fBwofi\fR(7). They are placed in the config file in the format \fBmode\-example_opt=val\fR. For example dmenu has an option called \fBparse_action\fR which would be placed in the config as \fBdmenu\-parse_action=true\fR.
Anything following a # is considered to be a comment unless the # is prefixed with a \\. For this reason in order to put a backslash in the config it must be escaped as well giving \\\\.
.SH CONFIG OPTIONS
Most of the options here are the command flags as found in \fBwofi\fR(1) in snake case, however some are unique to the config.
.TP
.B style=\fIPATH\fR
Specifies the CSS file to use as the stylesheet.
.TP
.B stylesheet=\fIPATH\fR
Specifies the CSS file to use as the stylesheet. This option is NOT the same as \fBstyle\fR. Absolute paths are absolute however relative paths are relative to the wofi config folder location $XDG_CONFIG_HOME/wofi and NOT the current working directory as they are with \fBstyle\fR. They are also NOT relative to the path as specified by \fB\-\-conf\fR. This option comes from rootbar and is probably more confusing than it's worth. You should probably use \fBstyle\fR unless you're sure this is what you want.
.TP
.B color=\fIPATH\fR
Specifies the colors file to use.
.TP
.B colors=\fIPATH\fR
Specifies the colors file to use. This option is NOT the same as \fBcolor\fR. Absolute paths are absolute however relative paths are relative to the wofi config folder location $XDG_CONFIG_HOME/wofi and NOT the current working directory as they are with \fBcolor\fR. They are also NOT relative to the path as specified by \fB\-\-conf\fR. This option comes from rootbar and is probably more confusing than it's worth. You should probably use \fBcolor\fR unless you're sure this is what you want.
.TP
.B show=\fIMODE\fR
Specifies the mode to run in. A list of modes can be found in \fBwofi\fR(7).
.TP
.B mode=\fIMODE\fR
Identical to \fBshow\fR.
.TP
.B width=\fIWIDTH\fR
Specifies the menu width in pixels or percent of screen size, default is 50%. Pixels are used unless the number ends with a %.
.TP
.B height=\fIHEIGHT\fR
Specifies the menu height in pixels or percent of screen size, default is 40%. Pixels are used unless the number ends with a %.
.TP
.B prompt=\fIPROMPT\fR
Sets the prompt to be display in the search box, default is the name of the mode.
.TP
.B xoffset=\fIOFFSET\fR
Sets the x offset from the location in pixels, default is 0.
.TP
.B x=\fIOFFSET\fR
Identical to \fBxoffset\fR.
.TP
.B yoffset=\fIOFFSET\fR
Sets the y offset from the location in pixels, default is 0.
.TP
.B y=\fIOFFSET\fR
Identical to \fByoffset\fR.
.TP
.B normal_window=\fIBOOL\fR
If true runs wofi in a normal window instead of using wlr\-layer\-shell, default is false.
.TP
.B allow_images=\fIBOOL\fR
If true allows image escape sequences to be processed and rendered, default is false.
.TP
.B allow_markup=\fIBOOL\fR
If true allows pango markup to be processed and rendered, default is false.
.TP
.B cache_file=\fIPATH\fR
Specifies the cache file to load/store cache, default is $XDG_CACHE_HOME/wofi\-<mode name> where <mode name> is the name of the mode, if $XDG_CACHE_HOME is not specified ~/.cache is used.
.TP
.B term=\fITERM\fR
Specifies the term to use when running a program in a terminal. This overrides the default terminal run order which is kitty, alacritty, wezterm, foot, termite, gnome\-terminal, weston\-terminal in that order.
.TP
.B password=\fICHARACTER\fR
Runs wofi in password mode using the specified character, default is false.
.TP
.B exec_search=\fIBOOL\fR
If true activiating a search with enter will execute the search not the first result, default is false.
.TP
.B hide_scroll=\fIBOOL\fR
If true hides the scroll bars, default is false.
.TP
.B matching=\fIMODE\fR
Specifies the matching mode, it can be either contains, multi-contains, or fuzzy, default is contains.
.TP
.B insensitive=\fIBOOL\fR
If true enables case insensitive search, default is false.
.TP
.B parse_search=\fIBOOL\fR
If true parses out image escapes and pango preventing them from being used for searching, default is false.
.TP
.B location=\fILOCATION\fR
Specifies the location. See \fBwofi\fR(7) for more information, default is center.
.TP
.B no_actions=\fIBOOL\fR
If true disables multiple actions for modes that support it, default is false.
.TP
.B lines=\fILINES\fR
Specifies the height in number of lines instead of pixels.
.TP
.B columns=\fICOLUMNS\fR
Specifies the number of columns to display, default is 1.
.TP
.B sort_order=\fIORDER\fR
Specifies the default sort order. There are currently two orders, default and alphabetical. See \fBwofi\fR(7) for details.
.TP
.B gtk_dark=\fIBOOL\fR
If true, instructs wofi to use the dark variant of the current GTK theme (if available). Default is false.
.TP
.B search=\fISTRING\fR
Specifies something to search for immediately on opening
.TP
.B monitor=\fISTRING\fR
Sets the monitor to open on
.TP
.B pre_display_cmd=\fICOMMAND\fR
Specifies a printf-like string which is used on the entries prior to displaying them. This command is only used to represent the label widget's string, and won't affect the the output of the selected label.
.TP
.B orientation=\fIORIENTATION\fR
Specifies the orientation, it can be either horizontal or vertical, default is vertical.
.TP
.B halign=\fIALIGN\fR
Specifies the horizontal align for the entire scrolled area, it can be any of fill, start, end, or center, default is fill.
.TP
.B content_halign=\fIALIGN\fR
Specifies the horizontal align for the individual entries, it can be any of fill, start, end, or center, default is fill.
.TP
.B valign=\fIALIGN\fR
Specifies the vertical align for the entire scrolled area, it can be any of fill, start, end, or center, the default is orientation dependent. If vertical then it defaults to start, if horizontal it defaults to center.
.TP
.B filter_rate=\fIRATE\fR
Specifies the rate at which search results are updated in milliseconds, default is 100.
.TP
.B image_size=\fISIZE\fR
Specifies the size of images in pixels when images are enabled, default is 32.
.TP
.B key_up=\fIKEY\fR
Specifies the key to use in order to move up. Default is Up(Up arrow). See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_down=\fIKEY\fR
Specifies the key to use in order to move down. Default is Down(Down arrow). See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_left=\fIKEY\fR
Specifies the key to use in order to move left. Default is Left(Left arrow). See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_right=\fIKEY\fR
Specifies the key to use in order to move right. Default is Right(Right arrow). See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_forward=\fIKEY\fR
Specifies the key to use in order to move forward. Default is Tab. See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_backward=\fIKEY\fR
Specifies the key to use in order to move backward. Default is ISO_Left_Tab(Shift+Tab). See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_submit=\fIKEY\fR
Specifies the key to use in order to submit an action. Default is Return. See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_exit=\fIKEY\fR
Specifies the key to use in order to exit wofi. Default is Escape. See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_pgup=\fIKEY\fR
Specifies the key to use in order to move one page up. Default is Page_Up. See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_pgdn=\fIKEY\fR
Specifies the key to use in order to move one page down. Default is Page_Down. See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_expand=\fIKEY\fR
Specifies the key to use in order to expand/contract multi-action entires. There is no default. See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_hide_search=\fIKEY\fR
Specifies the key to use in order to hide/show the search bar. There is no default. See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_copy=\fIKEY\fR
Specifies the key to use in order to copy the action text for the current entry. The default is Ctrl-c. See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_custom_(n)=\fIKEY\fR
Allows for configuring custom exit codes. For example setting key_custom_0=Ctrl-0 will make it so if you press Ctrl-0 wofi will set its exit status to 10. This will not cause wofi to exit, it will only set its exit code for when it does. 20 of these keys are configurable numbered 0-19. The exit status used is 10+n where n is the number attached to key_custom_n. There are no defaults for these. See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B line_wrap=\fIMODE\fR
Specifies the line wrap mode to use. The options are off, word, char, and word_char. Default is off.
.TP
.B global_coords=\fIBOOL\fR
Specifies whether x and y offsets should be calculated using the global compositor space instead of the current monitor. Default is false. This does not play well with locations and using it with them is not advised.
.TP
.B hide_search=\fIBOOL\fR
Specifies whether the search bar should be hidden. Default is false.
.TP
.B dynamic_lines=\fIBOOL\fR
Specifies whether wofi should be dynamically shrunk to fit the number of visible lines or if it should always stay the same size. Default is false.
.TP
.B layer=\fILAYER\fR
Specifies the layer to open on. The options are background, bottom, top, and overlay. Default is top
.TP
.B copy_exec=\fIPATH\fR
Specifies the executable to pipe copy data into. $PATH will be scanned, this is not passed to a shell and must be an executable. Default is wl-copy.
.TP
.B single_click=\fIBOOL\fR
Specifies whether or not actions should be executed on a single click or a double click. Default is false.
.TP
.B pre_display_exec=\fIBOOL\fR
This modifies the behavior of pre_display_cmd and causes the command in question to be directly executed via fork/exec rather than through the shell.
.SH CSS SELECTORS
Any GTK widget can be selected by using the name of its CSS node, these however might change with updates and are not guaranteed to stay constant. Wofi also provides certain widgets with names and classes which can be referenced from CSS to give access to the most important widgets easily. \fBwofi\fR(7) contains the current widget layout used by wofi so if you want to get into CSS directly using GTK widget names look there for info.
.TP
.B #window
.br
The name of the window itself.
.TP
.B #outer\-box
.br
The name of the box that contains everything.
.TP
.B #input
.br
The name of the search bar.
.TP
.B #scroll
.br
The name of the scrolled window containing all of the entries.
.TP
.B #inner\-box
.br
The name of the box containing all of the entries.
.TP
.B #img
.br
The name of all images in entries displayed in image mode.
.TP
.B #text
.br
The name of all the text in entries.
.TP
.B #unselected
.br
The name of all entries currently unselected. A better way of doing this is to do #entry and combine that with #entry:selected
.TP
.B #selected
.br
The name of all entries currently selected. A better way of doing this is to do #entry:selected
.TP
.B .entry
.br
The class attached to all entries. This is attached to the inside property box and is old, you probably want #entry instead
.TP
.B #entry
.br
The name of all entries.
.TP
.B #expander-box
.br
The name of all boxes shown when expanding entries with multiple actions
.SH COLORS
The colors file should be formatted as new line separated hex values. These values should be in the standard HTML format and begin with a hash. These colors will be loaded however wofi doesn't know what color should be used for what so you must reference them from your CSS.
You can reference these from your CSS by doing \-\-wofi\-color<n> where <n> is the line number \- 1. For example to reference the color on line 1 you would do \fB\-\-wofi\-color0\fR.
The colors can also be referenced by doing \-\-wofi\-rgb\-color<n> where <n> is the line number \- 1. The difference between these is the format used to replace the macro.
\-\-wofi\-color<n> is replaced with an HTML color code in the format #FFFFFF. \-\-wofi\-rgb\-color<n> is replaced with comma separated rgb values in the format 255, 255, 255. The correct usage of \-\-wofi\-rgb\-color<n> is to wrap it in rgb() or rgba(). Note that it does not return an alpha value so combining it with rgba() should be done like so \fBrgba(\-\-wofi\-rgb\-color0, 0.8)\fR. This would set the color to line 1 with an opacity of 80%.

View File

@ -1,194 +0,0 @@
.TH wofi 7
.SH NAME
wofi \- Built in modes and other features
.SH DESCRIPTION
Wofi contains several built in modes as well as a lot of other features including combi which are documented here.
The config options documented here are stripped of mode names. Mode specific config options are placed in the config file in the format \fBmode\-example_opt=val\fR. For example dmenu has an option called \fBparse_action\fR which would be placed in the config as \fBdmenu\-parse_action=true\fR.
.SH MODES
Currently wofi has 3 built in modes
.IP 1. 4
run \- searches $PATH for executables and allows them to be run by selecting them.
.IP 2. 4
drun \- searches $XDG_DATA_HOME/applications and $XDG_DATA_DIRS/applications for desktop files and allows them to be run by selecting them.
.IP 3. 4
dmenu \- reads from stdin and displays options which when selected will be output to stdout.
.P
In the event $XDG_DATA_HOME is not specified it defaults to ~/.local/share. If $XDG_DATA_DIRS is not specified it defaults to /usr/local/share:/usr/share.
Combi is not a mode however it does exist as a feature. You can use it by doing \-\-show mode1,mode2,mode3,etc. You can mix and match any number of modes however each mode can only be loaded once so doing something like \-\-show run,drun,run is not supported although I'm not sure why you'd do that in the first place.
.SH DMENU CONFIG OPTIONS
.TP
.B parse_action=\fIBOOL\fR
If true the result returned by dmenu will be stripped of image escape sequences and pango markup, default is false.
.TP
.B separator=\fICHAR\fR
The character used to separate dmenu entries, default is \\n.
.TP
.B print_line_num=\fIBOOL\fR
When an entry is selected the number of the line the entry was on is printed instead of the entry itself. This disables caching as it's fundamentally incompatible with it.
.SH RUN
In run mode holding ctrl while running an entry will cause arguments to be parsed even if always_parse_args=false. Holding shift will cause the entry to be run in a terminal.
.SH RUN CONFIG OPTIONS
.TP
.B always_parse_args=\fIBOOL\fR
If true spaces will not be treated as part of the executable name but rather as an argument separator equivalent to holding control while pressing enter, default is false.
.TP
.B show_all=\fIBOOL\fR
If true shows all the entries in path, this will show entries that have the same executable name, for example /bin/bash and /usr/bin/bash will be shown separately as bash instead of having one bash entry for the first one encountered, default is true.
.TP
.B print_command=\fIBOOL\fR
If true the executable that would be run will be printed to stdout instead of executing it, default is false.
.SH DRUN CONFIG OPTIONS
.TP
.B print_command=\fIBOOL\fR
If true the command used to launch the desktop file will be printed to stdout instead of invoking it, default is false.
.TP
.B display_generic=\fIBOOL\fR
If true then generic names will be displayed in () next to the application name, default is false.
.TP
.B disable_prime=\fIBOOL\fR
If true then wofi will ignore the PrefersNonDefaultGPU desktop variable, specifically this prevents wofi from setting DRI_PRIME, default is false.
.TP
.B print_desktop_file=\fIBOOL\fR
If true the path to the desktop file and the name of the corresponding action(if present) will be printed to stdout instead of invoking it, default is false.
.SH DRUN
When images are enabled drun mode will pull icon themes however being a GTK app it's possible you'll need to run gtk\-update\-icon\-cache to get them to apply.
.SH LOCATIONS
There are 9 possible locations which can be specified either by name or by number, the number scheme is the same as in rofi and the corresponding number is listed next to the names below, the default is center.
.IP 1. 4
center 0
.IP 2. 4
top_left 1
.IP 3. 4
top 2
.IP 4. 4
top_right 3
.IP 5. 4
right 4
.IP 6. 4
bottom_right 5
.IP 7. 4
bottom 6
.IP 8. 4
bottom_left 7
.IP 9. 4
left 8
.P
The x and y offsets are applied based on layer\-shell anchors which means an x offset can only be applied if wofi is anchored on the x axis, i.e. you can only use an x offset with the top_left, top_right, right, bottom_right, bottom_left, and left locations. center, top, and bottom can't have x offsets as they're not anchored on the x axis. Likewise y offsets can only be applied to top_left, top, top_right, bottom_right, bottom, and bottom_left locations. center, left, and right can't have y offsets because they're not anchored to the y axis. Since center can't have offsets on either as it's not anchored to any axis any x or y offset applied while using center will override the location to top_left for backwards compatibility reasons seeing as not doing so would simply ignore the offsets anyway.
.SH ORDER
There are 2 order options currently, default and alphabetical. Default means the entries are displayed in the order they are added by the mode, for all built in modes this is cached items first, followed by other entries in no specific order. Alphabetical means entries are alphabetical sorted period. These orders only affect the order when no search has been entered. Once a search is entered the order is re-arranged based on the current matching preference and this order is ignored.
.SH CACHING
Caching cannot be disabled however the cache file can be set to /dev/null to effectively disable it.
.SH WINDOW SWITCHER
Wofi does not have the ability to do window switching on its own as there is no way to do this with wayland/wlroots protocols however if you're using sway you can use swaymsg with dmenu mode to accomplish it.
The following script can be used to do window switching:
swaymsg \-t get_tree |
.br
jq \-r '.nodes[].nodes[] | if .nodes then [recurse(.nodes[])] else [] end + .floating_nodes | .[] | select(.nodes==[]) | ((.id | tostring) + " " + .name)' |
.br
wofi \-\-show dmenu | {
.br
read \-r id name
.br
swaymsg "[con_id=$id]" focus
.br
}
.SH WIDGET LAYOUT
This section is for advanced CSS which needs more control than the built in wofi CSS names/classes allow for. This widget layout is subject to change at any time and without warning so your CSS might very well break if you rely on this. Widgets have their corresponding names next to them if they have one.
.B window \- #window
.RS 4
.B box \- #outer\-box
.RS 4
.B entry \- #input
.B scrolledwindow \- #scroll
.RS 4
.B viewport
.RS 4
.B box
.RS 4
.B flowbox \- #inner\-box
.RS 4
.B flowboxchild \- #entry
.RS 4
.B .entry \- #unselected or #selected
.br
This only exists if there's ONLY 1 action. This is a WofiPropertyBox which has no CSS node and should probably not be used, the name is dependent on whether or not the entry is selected. See \fBwofi\fR(5) on #selected and #unselected for info.
.RS 4
.B image
.br
This is only present if an image is present in the entry and might occur multiple times if multiple images are present.
.B label
.br
This is only present if text is present in the entry and might occur multiple times if there are multiple text objects in a single entry.
.RE
.B expander
.br
This and its children only exist if there are multiple actions on the entry
.RS 4
.B .entry \- #unselected or #selected
.br
The main action. This is a WofiPropertyBox which has no CSS node and should probably not be used, the name is dependent on whether or not the entry is selected. See \fBwofi\fR(5) on #selected and #unselected for info.
.RS 4
.B image
.br
This is only present if an image is present in the entry and might occur multiple times if multiple images are present.
.B label
.br
This is only present if text is present in the entry and might occur multiple times if there are multiple text objects in a single entry.
.RE
.B list
.br
This contains all the secondary actions
.RS 4
.B row \- #entry
.RS 4
.B .entry \- #unselected or #selected
.br
This is a WofiPropertyBox which has no CSS node and should probably not be used, the name is dependent on whether or not the entry is selected. See \fBwofi\fR(5) on #selected and #unselected for info.
.RS 4
.B image
.br
This is only present if an image is present in the entry and might occur multiple times if multiple images are present.
.B label
.br
This is only present if text is present in the entry and might occur multiple times if there are multiple text objects in a single entry.
.RE
.RE
.RE
.RE
.RE
.RE
.RE
.RE
.B scrollbar
.RE
.RE
.RE

View File

@ -1,77 +0,0 @@
project('wofi', 'c', version : 'hg', default_options : ['c_std=c99', 'buildtype=release', 'warning_level=2'])
cc = meson.get_compiler('c')
pkgcfg = import('pkgconfig')
inc = include_directories('inc')
gtk = dependency('gtk+-3.0')
wayland = dependency('wayland-client')
threads = dependency('threads')
dl = cc.find_library('dl')
hg = find_program('hg', native : true, required : false)
version = meson.project_version()
if hg.found()
version = run_command(hg, 'identify', check : true).stdout().strip()
endif
add_project_arguments('-D_GNU_SOURCE', '-DVERSION="' + version + '"', language : 'c')
add_project_link_arguments('-rdynamic', language : 'c')
sources = ['src/config.c',
'src/main.c',
'src/map.c',
'src/match.c',
'src/property_box.c',
'src/utils_g.c',
'src/utils.c',
'src/widget_builder.c',
'src/wofi.c',
'proto/wlr-layer-shell-unstable-v1-protocol.c',
'proto/xdg-output-unstable-v1-protocol.c',
'proto/xdg-shell-protocol.c']
deps = [gtk, wayland, dl, threads]
if get_option('enable_run')
sources += 'modes/run.c'
endif
if get_option('enable_drun')
sources += 'modes/drun.c'
deps += dependency('gio-unix-2.0')
endif
if get_option('enable_dmenu')
sources += 'modes/dmenu.c'
endif
install_man('man/wofi.1',
'man/wofi.3',
'man/wofi.5',
'man/wofi.7',
'man/wofi-api.3',
'man/wofi-config.3',
'man/wofi-keys.7',
'man/wofi-map.3',
'man/wofi-utils.3',
'man/wofi-widget-builder.3')
subdir = 'wofi-1'
install_headers('inc/config.h',
'inc/map.h',
'inc/utils_g.h',
'inc/utils.h',
'inc/widget_builder_api.h',
'inc/wofi_api.h',
subdir : subdir)
pkgcfg.generate(name : meson.project_name(),
description : 'Wofi API for developing modes',
requires : wayland,
subdirs : subdir)
executable(meson.project_name(), sources, include_directories : inc, dependencies : deps, install : true)

View File

@ -1,3 +0,0 @@
option('enable_run', type : 'boolean', value : true, description : 'Whether run mode should be enabled')
option('enable_drun', type : 'boolean', value : true, description : 'Whether drun mode should be enabled')
option('enable_dmenu', type : 'boolean', value : true, description : 'Whether dmenu mode should be enabled')

View File

@ -1,172 +0,0 @@
/*
* Copyright (C) 2019-2024 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <config.h>
#include <wofi_api.h>
#include <pango/pango.h>
static const char* arg_names[] = {"parse_action", "separator", "print_line_num"};
static bool parse_action;
static char* separator;
static bool print_line_num;
static struct mode* mode;
struct node {
struct widget* widget;
struct wl_list link;
};
static struct wl_list widgets;
void wofi_dmenu_init(struct mode* this, struct map* config) {
mode = this;
parse_action = strcmp(config_get(config, "parse_action", "false"), "true") == 0;
separator = config_get(config, "separator", "\n");
print_line_num = strcmp(config_get(config, "print_line_num", "false"), "true") == 0;
if(strcmp(separator, "\\n") == 0) {
separator = "\n";
} else if(strcmp(separator, "\\0") == 0) {
separator = "\0";
} else if(strcmp(separator, "\\t") == 0) {
separator = "\t";
}
wl_list_init(&widgets);
struct map* cached = map_init();
struct wl_list entries;
wl_list_init(&entries);
struct map* entry_map = map_init();
if(!isatty(STDIN_FILENO)) {
char* line = NULL;
size_t size = 0;
while(getdelim(&line, &size, separator[0], stdin) != -1) {
char* delim = strchr(line, separator[0]);
if(delim != NULL) {
*delim = 0;
}
struct cache_line* node = malloc(sizeof(struct cache_line));
node->line = strdup(line);
wl_list_insert(&entries, &node->link);
map_put(entry_map, line, "true");
}
free(line);
}
if(!print_line_num) {
struct wl_list* cache = wofi_read_cache(mode);
struct cache_line* node, *tmp;
wl_list_for_each_safe(node, tmp, cache, link) {
if(map_contains(entry_map, node->line)) {
map_put(cached, node->line, "true");
struct node* widget = malloc(sizeof(struct node));
widget->widget = wofi_create_widget(mode, &node->line, node->line, &node->line, 1);
wl_list_insert(&widgets, &widget->link);
} else {
wofi_remove_cache(mode, node->line);
}
free(node->line);
wl_list_remove(&node->link);
free(node);
}
free(cache);
}
map_free(entry_map);
uint16_t line_num = 0;
struct cache_line* node, *tmp;
wl_list_for_each_reverse_safe(node, tmp, &entries, link) {
if(!map_contains(cached, node->line)) {
char* action;
if(print_line_num) {
action = malloc(6);
snprintf(action, 6, "%u", line_num++);
} else {
action = strdup(node->line);
}
struct node* widget = malloc(sizeof(struct node));
widget->widget = wofi_create_widget(mode, &node->line, node->line, &action, 1);
wl_list_insert(&widgets, &widget->link);
free(action);
}
free(node->line);
wl_list_remove(&node->link);
free(node);
}
map_free(cached);
}
struct widget* wofi_dmenu_get_widget(void) {
struct node* node, *tmp;
wl_list_for_each_reverse_safe(node, tmp, &widgets, link) {
struct widget* widget = node->widget;
wl_list_remove(&node->link);
free(node);
return widget;
}
return NULL;
}
void wofi_dmenu_exec(const gchar* cmd) {
char* action = strdup(cmd);
if(parse_action) {
if(wofi_allow_images()) {
free(action);
action = wofi_parse_image_escapes(cmd);
}
if(wofi_allow_markup()) {
char* out;
pango_parse_markup(action, -1, 0, NULL, &out, NULL, NULL);
free(action);
action = out;
}
}
if(!print_line_num) {
wofi_write_cache(mode, cmd);
}
printf("%s\n", action);
free(action);
wofi_exit(0);
}
const char** wofi_dmenu_get_arg_names(void) {
return arg_names;
}
size_t wofi_dmenu_get_arg_count(void) {
return sizeof(arg_names) / sizeof(char*);
}
bool wofi_dmenu_no_entry(void) {
return true;
}

View File

@ -1,496 +0,0 @@
/*
* Copyright (C) 2019-2024 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <libgen.h>
#include <sys/stat.h>
#include <map.h>
#include <utils.h>
#include <config.h>
#include <utils_g.h>
#include <widget_builder_api.h>
#include <gtk/gtk.h>
#include <gio/gdesktopappinfo.h>
static const char* arg_names[] = {"print_command", "display_generic", "disable_prime", "print_desktop_file"};
static struct mode* mode;
struct desktop_entry {
char* full_path;
struct wl_list link;
};
static struct map* entries;
static struct wl_list desktop_entries;
static bool print_command;
static bool display_generic;
static bool disable_prime;
static bool print_desktop_file;
static char* get_search_text(char* file) {
GDesktopAppInfo* info = g_desktop_app_info_new_from_filename(file);
const char* name = g_app_info_get_display_name(G_APP_INFO(info));
const char* exec = g_app_info_get_executable(G_APP_INFO(info));
const char* description = g_app_info_get_description(G_APP_INFO(info));
const char* categories = g_desktop_app_info_get_categories(info);
const char* const* keywords = g_desktop_app_info_get_keywords(info);
const char* generic_name = g_desktop_app_info_get_generic_name(info);
char* keywords_str = strdup("");
if(keywords != NULL) {
for(size_t count = 0; keywords[count] != NULL; ++count) {
char* tmp = utils_concat(2, keywords_str, keywords[count]);
free(keywords_str);
keywords_str = tmp;
}
}
char* ret = utils_concat(7, name, file,
exec == NULL ? "" : exec,
description == NULL ? "" : description,
categories == NULL ? "" : categories,
keywords_str,
generic_name == NULL ? "" : generic_name);
free(keywords_str);
return ret;
}
static bool populate_widget(char* file, char* action, struct widget_builder* builder) {
GDesktopAppInfo* info = g_desktop_app_info_new_from_filename(file);
if(info == NULL || !g_app_info_should_show(G_APP_INFO(info)) ||
g_desktop_app_info_get_is_hidden(info)) {
return false;
}
const char* name;
char* generic_name = strdup("");
if(action == NULL) {
name = g_app_info_get_display_name(G_APP_INFO(info));
if(display_generic) {
const char* gname = g_desktop_app_info_get_generic_name(info);
if(gname != NULL) {
free(generic_name);
generic_name = utils_concat(3, " (", gname, ")");
}
}
} else {
name = g_desktop_app_info_get_action_name(info, action);
}
if(name == NULL) {
free(generic_name);
return false;
}
if(wofi_allow_images()) {
GIcon* icon = g_app_info_get_icon(G_APP_INFO(info));
GdkPixbuf* pixbuf;
if(G_IS_FILE_ICON(icon)) {
GFile* file = g_file_icon_get_file(G_FILE_ICON(icon));
char* path = g_file_get_path(file);
pixbuf = gdk_pixbuf_new_from_file(path, NULL);
} else {
GtkIconTheme* theme = gtk_icon_theme_get_default();
GtkIconInfo* info = NULL;
if(icon != NULL) {
const gchar* const* icon_names = g_themed_icon_get_names(G_THEMED_ICON(icon));
info = gtk_icon_theme_choose_icon_for_scale(theme, (const gchar**) icon_names, wofi_get_image_size(), wofi_get_window_scale(), 0);
}
if(info == NULL) {
info = gtk_icon_theme_lookup_icon_for_scale(theme, "application-x-executable", wofi_get_image_size(), wofi_get_window_scale(), 0);
}
pixbuf = gtk_icon_info_load_icon(info, NULL);
}
if(pixbuf == NULL) {
goto img_fail;
}
pixbuf = utils_g_resize_pixbuf(pixbuf, wofi_get_image_size() * wofi_get_window_scale(), GDK_INTERP_BILINEAR);
wofi_widget_builder_insert_image(builder, pixbuf, "icon", NULL);
g_object_unref(pixbuf);
}
img_fail:
wofi_widget_builder_insert_text(builder, name, "name", NULL);
wofi_widget_builder_insert_text(builder, generic_name, "generic-name", NULL);
free(generic_name);
if(action == NULL) {
wofi_widget_builder_set_action(builder, file);
} else {
char* action_txt = utils_concat(3, file, " ", action);
wofi_widget_builder_set_action(builder, action_txt);
free(action_txt);
}
char* search_txt = get_search_text(file);
wofi_widget_builder_set_search_text(builder, search_txt);
free(search_txt);
return true;
}
static const gchar* const* get_actions(char* file, size_t* action_count) {
*action_count = 0;
GDesktopAppInfo* info = g_desktop_app_info_new_from_filename(file);
if(info == NULL) {
return NULL;
}
const gchar* const* actions = g_desktop_app_info_list_actions(info);
if(actions[0] == NULL) {
return NULL;
}
for(; actions[*action_count] != NULL; ++*action_count);
return actions;
}
static struct widget_builder* populate_actions(char* file, size_t* text_count) {
const gchar* const* action_names = get_actions(file, text_count);
++*text_count;
struct widget_builder* builder = wofi_widget_builder_init(mode, *text_count);
if(!populate_widget(file, NULL, builder)) {
wofi_widget_builder_free(builder);
return NULL;
}
for(size_t count = 1; count < *text_count; ++count) {
populate_widget(file, (gchar*) action_names[count - 1], wofi_widget_builder_get_idx(builder, count));
}
return builder;
}
static char* get_id(char* path) {
char* applications = strstr(path, "applications/");
if(applications == NULL) {
return NULL;
}
char* name = strchr(applications, '/') + 1;
char* id = strdup(name);
char* slash;
while((slash = strchr(id, '/')) != NULL) {
*slash = '-';
}
return id;
}
static struct widget* create_widget(char* full_path) {
char* id = get_id(full_path);
if(id == NULL) {
free(full_path);
return NULL;
}
if(map_contains(entries, id)) {
free(id);
free(full_path);
return NULL;
}
map_put(entries, id, "true");
size_t action_count;
struct widget_builder* builder = populate_actions(full_path, &action_count);
if(builder == NULL) {
wofi_remove_cache(mode, full_path);
free(id);
free(full_path);
return NULL;
}
struct widget* ret = wofi_widget_builder_get_widget(builder);
free(id);
free(full_path);
return ret;
}
static void insert_dir(char* app_dir) {
DIR* dir = opendir(app_dir);
if(dir == NULL) {
return;
}
struct dirent* entry;
while((entry = readdir(dir)) != NULL) {
if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
continue;
}
char* full_path = utils_concat(3, app_dir, "/", entry->d_name);
char* id = get_id(full_path);
if(id == NULL) {
free(full_path);
continue;
}
struct stat info;
stat(full_path, &info);
if(S_ISDIR(info.st_mode)) {
insert_dir(full_path);
free(id);
free(full_path);
continue;
}
if(map_contains(entries, id)) {
free(id);
free(full_path);
continue;
}
struct desktop_entry* entry = malloc(sizeof(struct desktop_entry));
entry->full_path = full_path;
wl_list_insert(&desktop_entries, &entry->link);
free(id);
}
closedir(dir);
}
static char* get_data_dirs(void) {
char* data_dirs = getenv("XDG_DATA_DIRS");
if(data_dirs == NULL) {
data_dirs = "/usr/local/share:/usr/share";
}
return strdup(data_dirs);
}
static char* get_data_home(void) {
char* data_home = getenv("XDG_DATA_HOME");
if(data_home == NULL) {
data_home = utils_concat(2, getenv("HOME"), "/.local/share");
} else {
data_home = strdup(data_home);
}
return data_home;
}
static bool starts_with_data_dirs(char* path) {
char* data_dirs = get_data_dirs();
char* save_ptr;
char* str = strtok_r(data_dirs, ":", &save_ptr);
do {
char* tmpstr = utils_concat(2, str, "/applications");
char* tmp = strdup(path);
char* dir = dirname(tmp);
if(strcmp(dir, tmpstr) == 0) {
free(tmp);
free(data_dirs);
free(tmpstr);
return true;
}
free(tmp);
free(tmpstr);
} while((str = strtok_r(NULL, ":", &save_ptr)) != NULL);
free(data_dirs);
return false;
}
static bool should_invalidate_cache(char* path) {
if(starts_with_data_dirs(path)) {
char* data_home = get_data_home();
char* tmp = strdup(path);
char* file = basename(tmp);
char* full_path = utils_concat(3, data_home, "/applications/", file);
free(data_home);
if(access(full_path, F_OK) == 0) {
free(full_path);
free(tmp);
return true;
}
free(full_path);
free(tmp);
}
return false;
}
void wofi_drun_init(struct mode* this, struct map* config) {
mode = this;
print_command = strcmp(config_get(config, "print_command", "false"), "true") == 0;
display_generic = strcmp(config_get(config, "display_generic", "false"), "true") == 0;
disable_prime = strcmp(config_get(config, "disable_prime", "false"), "true") == 0;
print_desktop_file = strcmp(config_get(config, "print_desktop_file", "false"), "true") == 0;
entries = map_init();
struct wl_list* cache = wofi_read_cache(mode);
wl_list_init(&desktop_entries);
struct cache_line* node, *tmp;
wl_list_for_each_safe(node, tmp, cache, link) {
if(should_invalidate_cache(node->line)) {
wofi_remove_cache(mode, node->line);
free(node->line);
goto cache_cont;
}
struct desktop_entry* entry = malloc(sizeof(struct desktop_entry));
entry->full_path = node->line;
wl_list_insert(&desktop_entries, &entry->link);
cache_cont:
wl_list_remove(&node->link);
free(node);
}
free(cache);
char* data_home = get_data_home();
char* data_dirs = get_data_dirs();
char* dirs = utils_concat(3, data_home, ":", data_dirs);
free(data_home);
free(data_dirs);
char* save_ptr;
char* str = strtok_r(dirs, ":", &save_ptr);
do {
char* app_dir = utils_concat(2, str, "/applications");
insert_dir(app_dir);
free(app_dir);
} while((str = strtok_r(NULL, ":", &save_ptr)) != NULL);
free(dirs);
}
struct widget* wofi_drun_get_widget(void) {
struct desktop_entry* node, *tmp;
wl_list_for_each_reverse_safe(node, tmp, &desktop_entries, link) {
struct widget* widget = create_widget(node->full_path);
wl_list_remove(&node->link);
free(node);
if(widget == NULL) {
continue;
}
return widget;
}
return NULL;
}
static void launch_done(GObject* obj, GAsyncResult* result, gpointer data) {
GError* err = NULL;
if(g_app_info_launch_uris_finish(G_APP_INFO(obj), result, &err)) {
wofi_exit(0);
} else if(err != NULL) {
char* cmd = data;
fprintf(stderr, "%s cannot be executed: %s\n", cmd, err->message);
g_error_free(err);
} else {
char* cmd = data;
fprintf(stderr, "%s cannot be executed\n", cmd);
}
wofi_exit(1);
}
static void set_dri_prime(GDesktopAppInfo* info) {
bool dri_prime = g_desktop_app_info_get_boolean(info, "PrefersNonDefaultGPU");
if(dri_prime && !disable_prime) {
setenv("DRI_PRIME", "1", true);
}
}
static bool uses_dbus(GDesktopAppInfo* info) {
return g_desktop_app_info_get_boolean(info, "DBusActivatable");
}
static char* get_cmd(GAppInfo* info) {
const char* cmd = g_app_info_get_commandline(info);
size_t cmd_size = strlen(cmd);
char* new_cmd = calloc(1, cmd_size + 1);
size_t new_cmd_count = 0;
for(size_t count = 0; count < cmd_size; ++count) {
if(cmd[count] == '%') {
if(cmd[++count] == '%') {
new_cmd[new_cmd_count++] = cmd[count];
}
} else {
new_cmd[new_cmd_count++] = cmd[count];
}
}
if(new_cmd[--new_cmd_count] == ' ') {
new_cmd[new_cmd_count] = 0;
}
return new_cmd;
}
void wofi_drun_exec(const gchar* cmd) {
GDesktopAppInfo* info = g_desktop_app_info_new_from_filename(cmd);
if(G_IS_DESKTOP_APP_INFO(info)) {
wofi_write_cache(mode, cmd);
if(print_command) {
char* cmd = get_cmd(G_APP_INFO(info));
printf("%s\n", cmd);
free(cmd);
wofi_exit(0);
} else if(print_desktop_file) {
printf("%s\n", cmd);
wofi_exit(0);
} else {
set_dri_prime(info);
if(uses_dbus(info)) {
g_app_info_launch_uris_async(G_APP_INFO(info), NULL, NULL, NULL, launch_done, (gchar*) cmd);
} else {
g_app_info_launch_uris(G_APP_INFO(info), NULL, NULL, NULL);
wofi_exit(0);
}
}
} else if(strrchr(cmd, ' ') != NULL) {
char* space = strrchr(cmd, ' ');
*space = 0;
wofi_write_cache(mode, cmd);
info = g_desktop_app_info_new_from_filename(cmd);
char* action = space + 1;
if(print_command) {
char* cmd = get_cmd(G_APP_INFO(info));
printf("%s\n", cmd);
free(cmd);
fprintf(stderr, "Printing the command line for an action is not supported\n");
} else if(print_desktop_file) {
printf("%s %s\n", cmd, action);
wofi_exit(0);
} else {
set_dri_prime(info);
g_desktop_app_info_launch_action(info, action, NULL);
}
wofi_exit(0);
} else {
fprintf(stderr, "%s cannot be executed\n", cmd);
wofi_exit(1);
}
}
const char** wofi_drun_get_arg_names(void) {
return arg_names;
}
size_t wofi_drun_get_arg_count(void) {
return sizeof(arg_names) / sizeof(char*);
}

View File

@ -1,231 +0,0 @@
/*
* Copyright (C) 2019-2024 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <utils.h>
#include <config.h>
#include <wofi_api.h>
static const char* arg_names[] = {"always_parse_args", "show_all", "print_command"};
static bool always_parse_args;
static bool show_all;
static bool print_command;
static struct mode* mode;
static const char* arg_str = "__args";
struct node {
struct widget* widget;
struct wl_list link;
};
static struct wl_list widgets;
void wofi_run_init(struct mode* this, struct map* config) {
mode = this;
always_parse_args = strcmp(config_get(config, arg_names[0], "false"), "true") == 0;
show_all = strcmp(config_get(config, arg_names[1], "true"), "true") == 0;
print_command = strcmp(config_get(config, arg_names[2], "false"), "true") == 0;
wl_list_init(&widgets);
struct map* cached = map_init();
struct wl_list* cache = wofi_read_cache(mode);
struct map* entries = map_init();
struct cache_line* node, *tmp;
wl_list_for_each_safe(node, tmp, cache, link) {
char* text = node->line;
if(strncmp(node->line, arg_str, strlen(arg_str)) == 0) {
text = strchr(text, ' ') + 1;
}
char* full_path = text;
char* final_slash = strrchr(text, '/');
if(final_slash != NULL) {
text = final_slash + 1;
}
struct stat info;
stat(node->line, &info);
if(((access(node->line, X_OK) == 0 && S_ISREG(info.st_mode)) ||
strncmp(node->line, arg_str, strlen(arg_str)) == 0) && !map_contains(cached, full_path)) {
struct node* widget = malloc(sizeof(struct node));
widget->widget = wofi_create_widget(mode, &text, text, &node->line, 1);
wl_list_insert(&widgets, &widget->link);
map_put(cached, full_path, "true");
map_put(entries, text, "true");
} else {
wofi_remove_cache(mode, node->line);
}
free(node->line);
wl_list_remove(&node->link);
free(node);
}
free(cache);
char* path = strdup(getenv("PATH"));
struct map* paths = map_init();
char* save_ptr;
char* str = strtok_r(path, ":", &save_ptr);
do {
str = realpath(str, NULL);
if(str == NULL) {
continue;
}
if(map_contains(paths, str)) {
free(str);
continue;
}
map_put(paths, str, "true");
DIR* dir = opendir(str);
if(dir == NULL) {
continue;
}
struct dirent* entry;
while((entry = readdir(dir)) != NULL) {
if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
continue;
}
char* full_path = utils_concat(3, str, "/", entry->d_name);
struct stat info;
stat(full_path, &info);
if(access(full_path, X_OK) == 0 && S_ISREG(info.st_mode) &&
!map_contains(cached, full_path) &&
(show_all || !map_contains(entries, entry->d_name))) {
char* text = strdup(entry->d_name);
map_put(entries, text, "true");
struct node* widget = malloc(sizeof(struct node));
widget->widget = wofi_create_widget(mode, &text, text, &full_path, 1);
wl_list_insert(&widgets, &widget->link);
free(text);
}
free(full_path);
}
free(str);
closedir(dir);
} while((str = strtok_r(NULL, ":", &save_ptr)) != NULL);
free(path);
map_free(paths);
map_free(cached);
map_free(entries);
}
struct widget* wofi_run_get_widget(void) {
struct node* node, *tmp;
wl_list_for_each_reverse_safe(node, tmp, &widgets, link) {
struct widget* widget = node->widget;
wl_list_remove(&node->link);
free(node);
return widget;
}
return NULL;
}
static char* parse_args(const char* cmd, size_t* space_count) {
size_t cmd_l = strlen(cmd);
char* ret = calloc(1, cmd_l + 1);
bool in_quote = false;
size_t ret_count = 0;
for(size_t count = 0; count < cmd_l; ++count) {
if(cmd[count] == ' ' && !in_quote) {
++*space_count;
ret[ret_count++] = '\n';
continue;
}
if(cmd[count] == '"') {
in_quote = !in_quote;
continue;
}
if(cmd[count] == '\\') {
++count;
}
ret[ret_count++] = cmd[count];
}
return ret;
}
void wofi_run_exec(const char* cmd) {
bool arg_run = wofi_mod_control() || always_parse_args;
if(strncmp(cmd, arg_str, strlen(arg_str)) == 0) {
arg_run = true;
cmd = strchr(cmd, ' ') + 1;
}
if(wofi_mod_shift()) {
wofi_write_cache(mode, cmd);
wofi_term_run(cmd);
}
if(print_command) {
printf("%s\n", cmd);
wofi_exit(0);
}
if(arg_run) {
size_t space_count = 2;
char* tmp = parse_args(cmd, &space_count);
char** args = malloc(space_count * sizeof(char*));
char* save_ptr;
char* str = strtok_r(tmp, "\n", &save_ptr);
size_t count = 0;
do {
args[count++] = str;
} while((str = strtok_r(NULL, "\n", &save_ptr)) != NULL);
args[space_count - 1] = NULL;
char* cache = utils_concat(2, "__args ", cmd);
wofi_write_cache(mode, cache);
free(cache);
execvp(tmp, args);
} else {
wofi_write_cache(mode, cmd);
execl(cmd, cmd, NULL);
}
fprintf(stderr, "%s cannot be executed %s\n", cmd, strerror(errno));
wofi_exit(errno);
}
const char** wofi_run_get_arg_names(void) {
return arg_names;
}
size_t wofi_run_get_arg_count(void) {
return sizeof(arg_names) / sizeof(char*);
}
bool wofi_run_no_entry(void) {
return true;
}

View File

@ -1,91 +0,0 @@
/* Generated by wayland-scanner 1.16.0 */
/*
* Copyright © 2017 Drew DeVault
*
* Permission to use, copy, modify, distribute, and sell this
* software and its documentation for any purpose is hereby granted
* without fee, provided that the above copyright notice appear in
* all copies and that both that copyright notice and this permission
* notice appear in supporting documentation, and that the name of
* the copyright holders not be used in advertising or publicity
* pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied
* warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
#include <stdlib.h>
#include <stdint.h>
#include "wayland-util.h"
#ifndef __has_attribute
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
#endif
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
#else
#define WL_PRIVATE
#endif
extern const struct wl_interface wl_output_interface;
extern const struct wl_interface wl_surface_interface;
extern const struct wl_interface xdg_popup_interface;
extern const struct wl_interface zwlr_layer_surface_v1_interface;
static const struct wl_interface *types[] = {
NULL,
NULL,
NULL,
NULL,
&zwlr_layer_surface_v1_interface,
&wl_surface_interface,
&wl_output_interface,
NULL,
NULL,
&xdg_popup_interface,
};
static const struct wl_message zwlr_layer_shell_v1_requests[] = {
{ "get_layer_surface", "no?ous", types + 4 },
};
WL_PRIVATE const struct wl_interface zwlr_layer_shell_v1_interface = {
"zwlr_layer_shell_v1", 1,
1, zwlr_layer_shell_v1_requests,
0, NULL,
};
static const struct wl_message zwlr_layer_surface_v1_requests[] = {
{ "set_size", "uu", types + 0 },
{ "set_anchor", "u", types + 0 },
{ "set_exclusive_zone", "i", types + 0 },
{ "set_margin", "iiii", types + 0 },
{ "set_keyboard_interactivity", "u", types + 0 },
{ "get_popup", "o", types + 9 },
{ "ack_configure", "u", types + 0 },
{ "destroy", "", types + 0 },
};
static const struct wl_message zwlr_layer_surface_v1_events[] = {
{ "configure", "uuu", types + 0 },
{ "closed", "", types + 0 },
};
WL_PRIVATE const struct wl_interface zwlr_layer_surface_v1_interface = {
"zwlr_layer_surface_v1", 1,
8, zwlr_layer_surface_v1_requests,
2, zwlr_layer_surface_v1_events,
};

View File

@ -1,78 +0,0 @@
/* Generated by wayland-scanner 1.16.0 */
/*
* Copyright © 2017 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdint.h>
#include "wayland-util.h"
#ifndef __has_attribute
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
#endif
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
#else
#define WL_PRIVATE
#endif
extern const struct wl_interface wl_output_interface;
extern const struct wl_interface zxdg_output_v1_interface;
static const struct wl_interface *types[] = {
NULL,
NULL,
&zxdg_output_v1_interface,
&wl_output_interface,
};
static const struct wl_message zxdg_output_manager_v1_requests[] = {
{ "destroy", "", types + 0 },
{ "get_xdg_output", "no", types + 2 },
};
WL_PRIVATE const struct wl_interface zxdg_output_manager_v1_interface = {
"zxdg_output_manager_v1", 2,
2, zxdg_output_manager_v1_requests,
0, NULL,
};
static const struct wl_message zxdg_output_v1_requests[] = {
{ "destroy", "", types + 0 },
};
static const struct wl_message zxdg_output_v1_events[] = {
{ "logical_position", "ii", types + 0 },
{ "logical_size", "ii", types + 0 },
{ "done", "", types + 0 },
{ "name", "2s", types + 0 },
{ "description", "2s", types + 0 },
};
WL_PRIVATE const struct wl_interface zxdg_output_v1_interface = {
"zxdg_output_v1", 2,
1, zxdg_output_v1_requests,
5, zxdg_output_v1_events,
};

View File

@ -1,174 +0,0 @@
/* Generated by wayland-scanner 1.16.0 */
/*
* Copyright © 2008-2013 Kristian Høgsberg
* Copyright © 2013 Rafael Antognolli
* Copyright © 2013 Jasper St. Pierre
* Copyright © 2010-2013 Intel Corporation
* Copyright © 2015-2017 Samsung Electronics Co., Ltd
* Copyright © 2015-2017 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdint.h>
#include "wayland-util.h"
#ifndef __has_attribute
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
#endif
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
#else
#define WL_PRIVATE
#endif
extern const struct wl_interface wl_output_interface;
extern const struct wl_interface wl_seat_interface;
extern const struct wl_interface wl_surface_interface;
extern const struct wl_interface xdg_popup_interface;
extern const struct wl_interface xdg_positioner_interface;
extern const struct wl_interface xdg_surface_interface;
extern const struct wl_interface xdg_toplevel_interface;
static const struct wl_interface *types[] = {
NULL,
NULL,
NULL,
NULL,
&xdg_positioner_interface,
&xdg_surface_interface,
&wl_surface_interface,
&xdg_toplevel_interface,
&xdg_popup_interface,
&xdg_surface_interface,
&xdg_positioner_interface,
&xdg_toplevel_interface,
&wl_seat_interface,
NULL,
NULL,
NULL,
&wl_seat_interface,
NULL,
&wl_seat_interface,
NULL,
NULL,
&wl_output_interface,
&wl_seat_interface,
NULL,
};
static const struct wl_message xdg_wm_base_requests[] = {
{ "destroy", "", types + 0 },
{ "create_positioner", "n", types + 4 },
{ "get_xdg_surface", "no", types + 5 },
{ "pong", "u", types + 0 },
};
static const struct wl_message xdg_wm_base_events[] = {
{ "ping", "u", types + 0 },
};
WL_PRIVATE const struct wl_interface xdg_wm_base_interface = {
"xdg_wm_base", 2,
4, xdg_wm_base_requests,
1, xdg_wm_base_events,
};
static const struct wl_message xdg_positioner_requests[] = {
{ "destroy", "", types + 0 },
{ "set_size", "ii", types + 0 },
{ "set_anchor_rect", "iiii", types + 0 },
{ "set_anchor", "u", types + 0 },
{ "set_gravity", "u", types + 0 },
{ "set_constraint_adjustment", "u", types + 0 },
{ "set_offset", "ii", types + 0 },
};
WL_PRIVATE const struct wl_interface xdg_positioner_interface = {
"xdg_positioner", 2,
7, xdg_positioner_requests,
0, NULL,
};
static const struct wl_message xdg_surface_requests[] = {
{ "destroy", "", types + 0 },
{ "get_toplevel", "n", types + 7 },
{ "get_popup", "n?oo", types + 8 },
{ "set_window_geometry", "iiii", types + 0 },
{ "ack_configure", "u", types + 0 },
};
static const struct wl_message xdg_surface_events[] = {
{ "configure", "u", types + 0 },
};
WL_PRIVATE const struct wl_interface xdg_surface_interface = {
"xdg_surface", 2,
5, xdg_surface_requests,
1, xdg_surface_events,
};
static const struct wl_message xdg_toplevel_requests[] = {
{ "destroy", "", types + 0 },
{ "set_parent", "?o", types + 11 },
{ "set_title", "s", types + 0 },
{ "set_app_id", "s", types + 0 },
{ "show_window_menu", "ouii", types + 12 },
{ "move", "ou", types + 16 },
{ "resize", "ouu", types + 18 },
{ "set_max_size", "ii", types + 0 },
{ "set_min_size", "ii", types + 0 },
{ "set_maximized", "", types + 0 },
{ "unset_maximized", "", types + 0 },
{ "set_fullscreen", "?o", types + 21 },
{ "unset_fullscreen", "", types + 0 },
{ "set_minimized", "", types + 0 },
};
static const struct wl_message xdg_toplevel_events[] = {
{ "configure", "iia", types + 0 },
{ "close", "", types + 0 },
};
WL_PRIVATE const struct wl_interface xdg_toplevel_interface = {
"xdg_toplevel", 2,
14, xdg_toplevel_requests,
2, xdg_toplevel_events,
};
static const struct wl_message xdg_popup_requests[] = {
{ "destroy", "", types + 0 },
{ "grab", "ou", types + 22 },
};
static const struct wl_message xdg_popup_events[] = {
{ "configure", "iiii", types + 0 },
{ "popup_done", "", types + 0 },
};
WL_PRIVATE const struct wl_interface xdg_popup_interface = {
"xdg_popup", 2,
2, xdg_popup_requests,
2, xdg_popup_events,
};

View File

@ -1,98 +0,0 @@
/*
* Copyright (C) 2019-2024 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <map.h>
void config_put(struct map* map, char* line) {
size_t line_size = strlen(line);
char* new_line = calloc(1, line_size + 1);
size_t new_line_count = 0;
for(size_t count = 0; count < line_size; ++count) {
if(line[count] == '\\') {
new_line[new_line_count++] = line[++count];
} else if(line[count] == '#') {
break;
} else {
new_line[new_line_count++] = line[count];
}
}
line = new_line;
char* equals = strchr(line, '=');
if(equals == NULL) {
free(line);
return;
}
*equals = 0;
char* key = equals - 1;
while(*key == ' ') {
--key;
}
*(key + 1) = 0;
char* value = equals + 1;
while(*value == ' ') {
++value;
}
size_t len = strlen(value);
char* end = value + len - 1;
if(*end == '\n' || *end == ' ') {
*end = 0;
}
map_put(map, line, value);
free(line);
}
void config_load(struct map* map, const char* config) {
FILE* file = fopen(config, "r");
char* line = NULL;
size_t size = 0;
while(getline(&line, &size, file) != -1) {
config_put(map, line);
}
free(line);
fclose(file);
}
char* config_get(struct map* config, const char* key, char* def_opt) {
char* opt = map_get(config, key);
if(opt == NULL) {
opt = def_opt;
}
return opt;
}
int config_get_mnemonic(struct map* config, const char* key, char* def_opt, int num_choices, ...) {
char* opt = config_get(config, key, def_opt);
va_list ap;
va_start(ap, num_choices);
int result = 0;
for(int i = 0; i < num_choices; i++) {
char* cmp_str = va_arg(ap, char*);
if(strcmp(opt, cmp_str) == 0) {
result = i;
break;
}
}
va_end(ap);
return result;
}

View File

@ -1,798 +0,0 @@
/*
* Copyright (C) 2019-2020 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#include <getopt.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <map.h>
#include <wofi.h>
#include <utils.h>
#include <config.h>
#include <wayland-client.h>
#include <gtk/gtk.h>
static const char* nyan_colors[] = {"#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#0000FF", "#FF00FF"};
static size_t nyan_color_l = sizeof(nyan_colors) / sizeof(char*);
static char* CONFIG_LOCATION;
static char* COLORS_LOCATION;
static struct map* config;
static char* config_path;
static char* stylesheet;
static char* color_path;
static uint8_t nyan_shift = 0;
struct option_node {
char* option;
struct wl_list link;
};
static char* get_exec_name(char* path) {
char* slash = strrchr(path, '/');
uint64_t offset;
if(slash == NULL) {
offset = 0;
} else {
offset = (slash - path) + 1;
}
return path + offset;
}
static void print_usage(char** argv) {
printf("%s [options]\n", get_exec_name(argv[0]));
printf("Options:\n");
printf("--help\t\t\t-h\tDisplays this help message\n");
printf("--fork\t\t\t-f\tForks the menu so you can close the terminal\n");
printf("--conf\t\t\t-c\tSelects a config file to use\n");
printf("--style\t\t\t-s\tSelects a stylesheet to use\n");
printf("--color\t\t\t-C\tSelects a colors file to use\n");
printf("--dmenu\t\t\t-d\tRuns in dmenu mode\n");
printf("--show\t\t\t-S\tSpecifies the mode to run in. A list can be found in wofi(7)\n");
printf("--width\t\t\t-W\tSpecifies the surface width\n");
printf("--height\t\t-H\tSpecifies the surface height\n");
printf("--prompt\t\t-p\tPrompt to display\n");
printf("--xoffset\t\t-x\tThe x offset\n");
printf("--yoffset\t\t-y\tThe y offset\n");
printf("--normal-window\t\t-n\tRender to a normal window\n");
printf("--allow-images\t\t-I\tAllows images to be rendered\n");
printf("--allow-markup\t\t-m\tAllows pango markup\n");
printf("--cache-file\t\t-k\tSets the cache file to use\n");
printf("--term\t\t\t-t\tSpecifies the terminal to use when running in a term\n");
printf("--password\t\t-P\tRuns in password mode\n");
printf("--exec-search\t\t-e\tMakes enter always use the search contents not the first result\n");
printf("--hide-scroll\t\t-b\tHides the scroll bars\n");
printf("--matching\t\t-M\tSets the matching method, default is contains\n");
printf("--insensitive\t\t-i\tAllows case insensitive searching\n");
printf("--parse-search\t\t-q\tParses the search text removing image escapes and pango\n");
printf("--version\t\t-v\tPrints the version and then exits\n");
printf("--location\t\t-l\tSets the location\n");
printf("--no-actions\t\t-a\tDisables multiple actions for modes that support it\n");
printf("--define\t\t-D\tSets a config option\n");
printf("--lines\t\t\t-L\tSets the height in number of lines\n");
printf("--columns\t\t-w\tSets the number of columns to display\n");
printf("--sort-order\t\t-O\tSets the sort order\n");
printf("--gtk-dark\t\t-G\tUses the dark variant of the current GTK theme\n");
printf("--search\t\t-Q\tSearch for something immediately on open\n");
printf("--monitor\t\t-o\tSets the monitor to open on\n");
printf("--pre-display-cmd\t-r\tRuns command for the displayed entries, without changing the output. %%s for the real string\n");
exit(0);
}
void wofi_load_css(bool nyan) {
if(access(stylesheet, R_OK) == 0) {
FILE* file = fopen(stylesheet, "r");
fseek(file, 0, SEEK_END);
ssize_t size = ftell(file);
fseek(file, 0, SEEK_SET);
char* data = malloc(size + 1);
if (fread(data, 1, size, file) == 0) {
fprintf(stderr, "failed to read stylesheet data from file\n");
exit(EXIT_FAILURE);
}
fclose(file);
data[size] = 0;
struct wl_list lines;
struct node {
char* line;
struct wl_list link;
};
wl_list_init(&lines);
if(nyan) {
for(ssize_t count = nyan_shift; count < 100 + nyan_shift; ++count) {
size_t i = count % nyan_color_l;
struct node* entry = malloc(sizeof(struct node));
entry->line = strdup(nyan_colors[i]);
wl_list_insert(&lines, &entry->link);
}
nyan_shift = (nyan_shift + 1) % nyan_color_l;
} else {
if(access(color_path, R_OK) == 0) {
file = fopen(color_path, "r");
char* line = NULL;
size_t line_size = 0;
ssize_t line_l = 0;
while((line_l = getline(&line, &line_size, file)) != -1) {
struct node* entry = malloc(sizeof(struct node));
line[line_l - 1] = 0;
entry->line = malloc(line_l + 1);
strcpy(entry->line, line);
wl_list_insert(&lines, &entry->link);
}
fclose(file);
free(line);
}
}
ssize_t count = wl_list_length(&lines) - 1;
if(count > 99) {
fprintf(stderr, "Woah there that's a lot of colors. Try having no more than 100, thanks\n");
exit(1);
}
struct node* node;
wl_list_for_each(node, &lines, link) {
//Do --wofi-color replace
const char* color = node->line;
const char* wofi_color = "--wofi-color";
char count_str[3];
snprintf(count_str, 3, "%zu", count--);
char* needle = utils_concat(2, wofi_color, count_str);
size_t color_len = strlen(color);
size_t needle_len = strlen(needle);
if(color_len > needle_len) {
free(needle);
fprintf(stderr, "What color format is this, try #FFFFFF, kthxbi\n");
continue;
}
char* replace = strstr(data, needle);
while(replace != NULL) {
memcpy(replace, color, color_len);
memset(replace + color_len, ' ', needle_len - color_len);
replace = strstr(data, needle);
}
free(needle);
//Do --wofi-rgb-color replace
if(color_len < 7) {
fprintf(stderr, "What color format is this, try #FFFFFF, kthxbi\n");
continue;
}
const char* wofi_rgb_color = "--wofi-rgb-color";
needle = utils_concat(2, wofi_rgb_color, count_str);
needle_len = strlen(needle);
replace = strstr(data, needle);
while(replace != NULL) {
char r[3];
char g[3];
char b[3];
memcpy(r, color + 1, 2);
memcpy(g, color + 3, 2);
memcpy(b, color + 5, 2);
r[2] = 0;
g[2] = 0;
b[2] = 0;
char rgb[14];
snprintf(rgb, 14, "%ld, %ld, %ld", strtol(r, NULL, 16), strtol(g, NULL, 16), strtol(b, NULL, 16));
size_t rgb_len = strlen(rgb);
memcpy(replace, rgb, rgb_len);
memset(replace + rgb_len, ' ', needle_len - rgb_len);
replace = strstr(data, needle);
}
free(needle);
}
GtkCssProvider* css = gtk_css_provider_new();
gtk_css_provider_load_from_data(css, data, strlen(data), NULL);
free(data);
struct node* tmp;
wl_list_for_each_safe(node, tmp, &lines, link) {
free(node->line);
wl_list_remove(&node->link);
free(node);
}
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
}
static void sig(int32_t signum) {
switch(signum) {
case SIGTERM:
exit(1);
break;
}
}
int main(int argc, char** argv) {
const struct option opts[] = {
{
.name = "help",
.has_arg = no_argument,
.flag = NULL,
.val = 'h'
},
{
.name = "fork",
.has_arg = no_argument,
.flag = NULL,
.val = 'f'
},
{
.name = "conf",
.has_arg = required_argument,
.flag = NULL,
.val = 'c'
},
{
.name = "style",
.has_arg = required_argument,
.flag = NULL,
.val = 's'
},
{
.name = "color",
.has_arg = required_argument,
.flag = NULL,
.val = 'C'
},
{
.name = "dmenu",
.has_arg = no_argument,
.flag = NULL,
.val = 'd'
},
{
.name = "show",
.has_arg = required_argument,
.flag = NULL,
.val = 'S'
},
{
.name = "width",
.has_arg = required_argument,
.flag = NULL,
.val = 'W'
},
{
.name = "height",
.has_arg = required_argument,
.flag = NULL,
.val = 'H'
},
{
.name = "prompt",
.has_arg = required_argument,
.flag = NULL,
.val = 'p'
},
{
.name = "xoffset",
.has_arg = required_argument,
.flag = NULL,
.val = 'x'
},
{
.name = "yoffset",
.has_arg = required_argument,
.flag = NULL,
.val = 'y'
},
{
.name = "normal-window",
.has_arg = no_argument,
.flag = NULL,
.val = 'n'
},
{
.name = "allow-images",
.has_arg = no_argument,
.flag = NULL,
.val = 'I'
},
{
.name = "allow-markup",
.has_arg = no_argument,
.flag = NULL,
.val = 'm'
},
{
.name = "cache-file",
.has_arg = required_argument,
.flag = NULL,
.val = 'k'
},
{
.name = "term",
.has_arg = required_argument,
.flag = NULL,
.val = 't'
},
{
.name = "password",
.has_arg = optional_argument,
.flag = NULL,
.val = 'P'
},
{
.name = "exec-search",
.has_arg = no_argument,
.flag = NULL,
.val = 'e'
},
{
.name = "hide-scroll",
.has_arg = no_argument,
.flag = NULL,
.val = 'b'
},
{
.name = "matching",
.has_arg = required_argument,
.flag = NULL,
.val = 'M'
},
{
.name = "insensitive",
.has_arg = no_argument,
.flag = NULL,
.val = 'i'
},
{
.name = "parse-search",
.has_arg = no_argument,
.flag = NULL,
.val = 'q'
},
{
.name = "version",
.has_arg = no_argument,
.flag = NULL,
.val = 'v'
},
{
.name = "location",
.has_arg = required_argument,
.flag = NULL,
.val = 'l'
},
{
.name = "no-actions",
.has_arg = no_argument,
.flag = NULL,
.val = 'a'
},
{
.name = "define",
.has_arg = required_argument,
.flag = NULL,
.val = 'D'
},
{
.name = "lines",
.has_arg = required_argument,
.flag = NULL,
.val = 'L'
},
{
.name = "columns",
.has_arg = required_argument,
.flag = NULL,
.val = 'w'
},
{
.name = "sort-order",
.has_arg = required_argument,
.flag = NULL,
.val = 'O'
},
{
.name = "gtk-dark",
.has_arg = no_argument,
.flag = NULL,
.val = 'G'
},
{
.name = "search",
.has_arg = required_argument,
.flag = NULL,
.val = 'Q'
},
{
.name = "monitor",
.has_arg = required_argument,
.flag = NULL,
.val = 'o'
},
{
.name = "pre-display-cmd",
.has_arg = required_argument,
.flag = NULL,
.val = 'r'
},
{
.name = NULL,
.has_arg = 0,
.flag = NULL,
.val = 0
}
};
const char* config_str = NULL;
char* style_str = NULL;
char* color_str = NULL;
char* mode = NULL;
char* prompt = NULL;
char* width = NULL;
char* height = NULL;
char* x = NULL;
char* y = NULL;
char* normal_window = NULL;
char* allow_images = NULL;
char* allow_markup = NULL;
char* cache_file = NULL;
char* terminal = NULL;
char* password_char = "false";
char* exec_search = NULL;
char* hide_scroll = NULL;
char* matching = NULL;
char* insensitive = NULL;
char* parse_search = NULL;
char* location = NULL;
char* no_actions = NULL;
char* lines = NULL;
char* columns = NULL;
char* sort_order = NULL;
char* gtk_dark = NULL;
char* search = NULL;
char* monitor = NULL;
char* pre_display_cmd = NULL;
struct wl_list options;
wl_list_init(&options);
struct option_node* node;
int opt;
while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nImk:t:P::ebM:iqvl:aD:L:w:O:GQ:o:r:", opts, NULL)) != -1) {
switch(opt) {
case 'h':
print_usage(argv);
break;
case 'f':
if(fork() > 0) {
exit(0);
}
fclose(stdout);
fclose(stderr);
fclose(stdin);
break;
case 'c':
config_str = optarg;
break;
case 's':
style_str = optarg;
break;
case 'C':
color_str = optarg;
break;
case 'd':
mode = "dmenu";
break;
case 'S':
mode = optarg;
break;
case 'W':
width = optarg;
break;
case 'H':
height = optarg;
break;
case 'p':
prompt = optarg;
break;
case 'x':
x = optarg;
break;
case 'y':
y = optarg;
break;
case 'n':
normal_window = "true";
break;
case 'I':
allow_images = "true";
break;
case 'm':
allow_markup = "true";
break;
case 'k':
cache_file = optarg;
break;
case 't':
terminal = optarg;
break;
case 'P':
password_char = optarg;
break;
case 'e':
exec_search = "true";
break;
case 'b':
hide_scroll = "true";
break;
case 'M':
matching = optarg;
break;
case 'i':
insensitive = "true";
break;
case 'q':
parse_search = "true";
break;
case 'v':
printf(VERSION"\n");
exit(0);
break;
case 'l':
location = optarg;
break;
case 'a':
no_actions = "true";
break;
case 'D':
node = malloc(sizeof(struct option_node));
node->option = optarg;
wl_list_insert(&options, &node->link);
break;
case 'L':
lines = optarg;
break;
case 'w':
columns = optarg;
break;
case 'O':
sort_order = optarg;
break;
case 'G':
gtk_dark = "true";
break;
case 'Q':
search = optarg;
break;
case 'o':
monitor = optarg;
break;
case 'r':
pre_display_cmd = optarg;
break;
}
}
const char* home_dir = getenv("HOME");
const char* xdg_conf = getenv("XDG_CONFIG_HOME");
if(xdg_conf == NULL) {
CONFIG_LOCATION = utils_concat(2, home_dir, "/.config/wofi");
} else {
CONFIG_LOCATION = utils_concat(2, xdg_conf, "/wofi");
}
const char* xdg_cache = getenv("XDG_CACHE_HOME");
if(xdg_cache == NULL) {
COLORS_LOCATION = utils_concat(2, home_dir, "/.cache/wal/colors");
} else {
COLORS_LOCATION = utils_concat(2, xdg_cache, "/wal/colors");
}
config = map_init();
//Check if --conf was specified
if(config_str == NULL) {
const char* config_f = "/config";
config_path = utils_concat(2, CONFIG_LOCATION, config_f);
} else {
config_path = strdup(config_str);
}
if(access(config_path, R_OK) == 0) {
config_load(config, config_path);
}
free(config_path);
if(style_str == NULL) {
style_str = map_get(config, "style");
}
//Check if --style was specified
if(style_str == NULL) {
style_str = map_get(config, "stylesheet");
if(style_str == NULL) {
const char* style_f = "/style.css";
stylesheet = utils_concat(2, CONFIG_LOCATION, style_f);
} else {
if(style_str[0] == '/') {
stylesheet = strdup(style_str);
} else {
stylesheet = utils_concat(3, CONFIG_LOCATION, "/", style_str);
}
}
} else {
stylesheet = strdup(style_str);
}
if(color_str == NULL) {
color_str = map_get(config, "color");
}
//Check if --color was specified
if(color_str == NULL) {
color_str = map_get(config, "colors");
if(color_str == NULL) {
color_path = strdup(COLORS_LOCATION);
} else {
if(color_str[0] == '/') {
color_path = strdup(color_str);
} else {
color_path = utils_concat(3, CONFIG_LOCATION, "/", color_str);
}
}
} else {
color_path = strdup(color_str);
}
//Check if --gtk-dark was specified
if(gtk_dark == NULL) {
gtk_dark = map_get(config, "gtk_dark");
}
free(COLORS_LOCATION);
struct option_node* tmp;
wl_list_for_each_safe(node, tmp, &options, link) {
config_put(config, node->option);
wl_list_remove(&node->link);
free(node);
}
if(map_get(config, "show") != NULL) {
map_put(config, "mode", map_get(config, "show"));
}
if(strcmp(get_exec_name(argv[0]), "dmenu") == 0) {
map_put(config, "mode", "dmenu");
cache_file = "/dev/null";
} else if(strcmp(get_exec_name(argv[0]), "wofi-askpass") == 0) {
map_put(config, "mode", "dmenu");
cache_file = "/dev/null";
password_char = "*";
prompt = "Password";
} else if(mode != NULL) {
map_put(config, "mode", mode);
} else if(map_get(config, "mode") == NULL) {
fprintf(stderr, "I need a mode, please give me a mode, that's what --show is for\n");
exit(1);
}
map_put(config, "config_dir", CONFIG_LOCATION);
if(width != NULL) {
map_put(config, "width", width);
}
if(height != NULL) {
map_put(config, "height", height);
}
if(prompt != NULL) {
map_put(config, "prompt", prompt);
}
if(map_get(config, "xoffset") != NULL) {
map_put(config, "x", map_get(config, "xoffset"));
}
if(x != NULL) {
map_put(config, "x", x);
}
if(map_get(config, "yoffset") != NULL) {
map_put(config, "y", map_get(config, "yoffset"));
}
if(y != NULL) {
map_put(config, "y", y);
}
if(normal_window != NULL) {
map_put(config, "normal_window", normal_window);
}
if(allow_images != NULL) {
map_put(config, "allow_images", allow_images);
}
if(allow_markup != NULL) {
map_put(config, "allow_markup", allow_markup);
}
if(cache_file != NULL) {
map_put(config, "cache_file", cache_file);
}
if(terminal != NULL) {
map_put(config, "term", terminal);
}
if(map_get(config, "password") != NULL) {
map_put(config, "password_char", map_get(config, "password"));
}
if(password_char == NULL || (password_char != NULL && strcmp(password_char, "false") != 0)) {
if(password_char == NULL) {
password_char = "*";
}
map_put(config, "password_char", password_char);
}
if(exec_search != NULL) {
map_put(config, "exec_search", exec_search);
}
if(hide_scroll != NULL) {
map_put(config, "hide_scroll", hide_scroll);
}
if(matching != NULL) {
map_put(config, "matching", matching);
}
if(insensitive != NULL) {
map_put(config, "insensitive", insensitive);
}
if(parse_search != NULL) {
map_put(config, "parse_search", parse_search);
}
if(location != NULL) {
map_put(config, "location", location);
}
if(no_actions != NULL) {
map_put(config, "no_actions", no_actions);
}
if(lines != NULL) {
map_put(config, "lines", lines);
}
if(columns != NULL) {
map_put(config, "columns", columns);
}
if(sort_order != NULL) {
map_put(config, "sort_order", sort_order);
}
if(search != NULL) {
map_put(config, "search", search);
}
if(monitor != NULL) {
map_put(config, "monitor", monitor);
}
if(pre_display_cmd != NULL) {
map_put(config, "pre_display_cmd", pre_display_cmd);
}
struct sigaction sigact = {0};
sigact.sa_handler = sig;
sigaction(SIGTERM, &sigact, NULL);
gtk_init(&argc, &argv);
if(gtk_dark != NULL && strcmp(gtk_dark, "true") == 0) {
g_object_set(gtk_settings_get_default(),
"gtk-application-prefer-dark-theme", TRUE, NULL);
}
wofi_load_css(false);
wofi_init(config);
gtk_main();
return 0;
}

View File

@ -1,96 +0,0 @@
/*
* Copyright (C) 2019-2020 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#include <map.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gmodule.h>
struct map {
GTree* tree;
bool mman;
};
static gint compare(gconstpointer p1, gconstpointer p2, gpointer data) {
(void) data;
const char* str1 = p1;
const char* str2 = p2;
return strcmp(str1, str2);
}
struct map* map_init(void) {
struct map* map = malloc(sizeof(struct map));
map->tree = g_tree_new_full(compare, NULL, free, free);
map->mman = true;
return map;
}
struct map* map_init_void(void) {
struct map* map = malloc(sizeof(struct map));
map->tree = g_tree_new_full(compare, NULL, free, NULL);
map->mman = false;
return map;
}
void map_free(struct map* map) {
g_tree_destroy(map->tree);
free(map);
}
static void put(struct map* map, const char* key, void* value) {
char* k = strdup(key);
char* v = value;
if(map->mman && value != NULL) {
v = strdup(value);
}
g_tree_insert(map->tree, k, v);
}
bool map_put(struct map* map, const char* key, char* value) {
if(map->mman) {
put(map, key, value);
return true;
} else {
fprintf(stderr, "This is an unmanaged map please use map_put_void\n");
return false;
}
}
bool map_put_void(struct map* map, const char* key, void* value) {
if(map->mman) {
fprintf(stderr, "This is an managed map please use map_put\n");
return false;
} else {
put(map, key, value);
return true;
}
}
void* map_get(struct map* map, const char* key) {
return g_tree_lookup(map->tree, key);
}
bool map_contains(struct map* map, const char* key) {
return map_get(map, key) != NULL;
}
size_t map_size(struct map* map) {
return g_tree_nnodes(map->tree);
}

View File

@ -1,412 +0,0 @@
/*
* Copyright (C) 2019-2022 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ctype.h>
#include <match.h>
#include <string.h>
// leading gap
#define SCORE_GAP_LEADING -0.005
// trailing gap
#define SCORE_GAP_TRAILING -0.005
// gap in the middle
#define SCORE_GAP_INNER -0.01
// we matched the characters consecutively
#define SCORE_MATCH_CONSECUTIVE 1.0
// we got a consecutive match, but insensitive is on
// and we didn't match the case.
#define SCORE_MATCH_NOT_MATCH_CASE 0.9
// we are matching after a slash
#define SCORE_MATCH_SLASH 0.9
// we are matching after a space dash or hyphen
#define SCORE_MATCH_WORD 0.8
// we are matching a camel case letter
#define SCORE_MATCH_CAPITAL 0.7
// we are matching after a dot
#define SCORE_MATCH_DOT 0.6
#define SWAP(x, y, T) \
do { \
T SWAP = x; \
x = y; \
y = SWAP; \
} while(0)
#define max(a, b) (((a) > (b)) ? (a) : (b))
// matching
static bool contains_match(const char* filter, const char* text, bool insensitive) {
if(filter == NULL || strcmp(filter, "") == 0) {
return true;
}
if(text == NULL) {
return false;
}
if(insensitive) {
return strcasestr(text, filter) != NULL;
} else {
return strstr(text, filter) != NULL;
}
}
static char* strcasechr(const char* s,char c, bool insensitive) {
if(insensitive) {
const char accept[3] = {tolower(c), toupper(c), 0};
return strpbrk(s, accept);
} else {
return strchr(s, c);
}
}
static bool fuzzy_match(const char* filter, const char* text, bool insensitive) {
if(filter == NULL || strcmp(filter, "") == 0) {
return true;
}
if(text == NULL) {
return false;
}
// we just check that all the characters (ignoring case) are in the
// search text possibly case insensitively in the correct order
while(*filter != 0) {
char nch = *filter++;
if(!(text = strcasechr(text, nch, insensitive))) {
return false;
}
text++;
}
return true;
}
static bool multi_contains_match(const char* filter, const char* text, bool insensitive) {
if(filter == NULL || strcmp(filter, "") == 0) {
return true;
}
if(text == NULL) {
return false;
}
char new_filter[MAX_MULTI_CONTAINS_FILTER_SIZE];
strncpy(new_filter, filter, sizeof(new_filter));
new_filter[sizeof(new_filter) - 1] = '\0';
char* token;
char* rest = new_filter;
while((token = strtok_r(rest, " ", &rest))) {
if(contains_match(token, text, insensitive) == false) {
return false;
}
}
return true;
}
bool match_for_matching_mode(const char* filter, const char* text,
enum matching_mode matching, bool insensitive) {
bool retval;
switch(matching) {
case MATCHING_MODE_MULTI_CONTAINS:
retval = multi_contains_match(filter, text, insensitive);
break;
case MATCHING_MODE_CONTAINS:
retval = contains_match(filter, text, insensitive);
break;
case MATCHING_MODE_FUZZY:
retval = fuzzy_match(filter, text, insensitive);
break;
default:
return false;
}
return retval;
}
// end matching
// fuzzy matching
static void precompute_bonus(const char* haystack, score_t* match_bonus) {
/* Which positions are beginning of words */
int m = strlen(haystack);
char last_ch = '\0';
for(int i = 0; i < m; i++) {
char ch = haystack[i];
score_t score = 0;
if(isalnum(ch)) {
if(!last_ch || last_ch == '/') {
score = SCORE_MATCH_SLASH;
} else if(last_ch == '-' || last_ch == '_' ||
last_ch == ' ') {
score = SCORE_MATCH_WORD;
} else if(last_ch >= 'a' && last_ch <= 'z' &&
ch >= 'A' && ch <= 'Z') {
/* CamelCase */
score = SCORE_MATCH_CAPITAL;
} else if(last_ch == '.') {
score = SCORE_MATCH_DOT;
}
}
match_bonus[i] = score;
last_ch = ch;
}
}
static inline bool match_with_case(char a, char b, bool insensitive) {
if(insensitive) {
return tolower(a) == tolower(b);
} else {
return a == b;
}
}
static inline void match_row(int row, score_t* curr_D, score_t* curr_M,
const score_t* last_D, const score_t* last_M,
const char* needle, const char* haystack, int n, int m, score_t* match_bonus, bool insensitive) {
int i = row;
score_t prev_score = SCORE_MIN;
score_t gap_score = i == n - 1 ? SCORE_GAP_TRAILING : SCORE_GAP_INNER;
for(int j = 0; j < m; j++) {
if(match_with_case(needle[i], haystack[j], insensitive)) {
score_t score = SCORE_MIN;
if(!i) {
// first line we fill in a row for non-matching
score = (j * SCORE_GAP_LEADING) + match_bonus[j];
} else if(j) { /* i > 0 && j > 0*/
// we definitely match case insensitively already so if
// our character isn't the same then we have a different case
score_t consecutive_bonus = needle[i] == haystack[j] ? SCORE_MATCH_CONSECUTIVE : SCORE_MATCH_NOT_MATCH_CASE;
score = max(last_M[j - 1] + match_bonus[j],
/* consecutive match, doesn't stack
with match_bonus */
last_D[j - 1] + consecutive_bonus);
}
curr_D[j] = score;
curr_M[j] = prev_score = max(score, prev_score + gap_score);
} else {
curr_D[j] = SCORE_MIN;
curr_M[j] = prev_score = prev_score + gap_score;
}
}
}
// Fuzzy matching scoring. Adapted from
// https://github.com/jhawthorn/fzy/blob/master/src/match.c and
// https://github.com/jhawthorn/fzy/blob/master/ALGORITHM.md
// For a fuzzy match string needle being searched for in haystack we provide a
// number score for how well we match.
// We create two matrices of size needle_len (n) by haystack_len (m).
// The first matrix is the score matrix. Each position (i,j) within this matrix
// consists of the score that corresponds to the score that would be generated
// by matching the first i characters of the needle with the first j
// characters of the haystack. Gaps have a fixed penalty for having a gap along
// with a linear penalty for gap size (c.f. gotoh's algorithm).
// matches give a positive score, with a slight weight given to matches after
// certain special characters (i.e. the first character after a `/` will be
// "almost" consecutive but lower than an actual consecutive match).
// Our second matrix is our diagonal matrix where we store the best match
// that ends at a match. This allows us to calculate our gap penalties alongside
// our consecutive match scores.
// In addition, since we only rely on the current, and previous row of the
// matrices and we only want to compute the score, we only store those scores
// and reuse the previous rows (rather than storing the entire (n*m) matrix).
// In addition we've simplified some of the algorithm compared to fzy to
// improve legibility. (Can reimplement lookup tables later if wanted.)
// Also, the reference algorithm does not take into account case sensitivity
// which has been implemented here.
static score_t fuzzy_score(const char* haystack, const char* needle, bool insensitive) {
if(*needle == 0)
return SCORE_MIN;
int n = strlen(needle);
int m = strlen(haystack);
score_t match_bonus[m];
precompute_bonus(haystack, match_bonus);
if(m > MATCH_FUZZY_MAX_LEN || n > m) {
/*
* Unreasonably large candidate: return no score
* If it is a valid match it will still be returned, it will
* just be ranked below any reasonably sized candidates
*/
return SCORE_MIN;
} else if(n == m) {
/* Since this method can only be called with a haystack which
* matches needle. If the lengths of the strings are equal the
* strings themselves must also be equal (ignoring case).
*/
return SCORE_MAX;
}
/*
* D[][] Stores the best score for this position ending with a match.
* M[][] Stores the best possible score at this position.
*/
score_t D[2][MATCH_FUZZY_MAX_LEN], M[2][MATCH_FUZZY_MAX_LEN];
score_t* last_D, *last_M;
score_t* curr_D, *curr_M;
last_D = D[0];
last_M = M[0];
curr_D = D[1];
curr_M = M[1];
for(int i = 0; i < n; i++) {
match_row(i, curr_D, curr_M, last_D, last_M, needle, haystack, n, m, match_bonus, insensitive);
SWAP(curr_D, last_D, score_t *);
SWAP(curr_M, last_M, score_t *);
}
return last_M[m - 1];
}
// end fuzzy matching
// sorting
static int fuzzy_sort(const char* text1, const char* text2, const char* filter, bool insensitive) {
bool match1 = fuzzy_match(filter, text1, insensitive);
bool match2 = fuzzy_match(filter, text2, insensitive);
// both filters match do fuzzy scoring
if(match1 && match2) {
score_t dist1 = fuzzy_score(text1, filter, insensitive);
score_t dist2 = fuzzy_score(text2, filter, insensitive);
if(dist1 == dist2) {
// same same
return 0;
} else if(dist1 > dist2) { // highest score wins.
// text1 goes first
return -1;
} else {
// text2 goes first
return 1;
}
} else if(match1) {
// text1 goes first
return -1;
} else if(match2) {
// text2 goes first
return 1;
} else {
// same same.
return 0;
}
}
// we sort based on how early in the string all the matches are.
// if there are matches for each.
static int multi_contains_sort(const char* text1, const char* text2, const char* filter, bool insensitive) {
// sum of string positions of each match
int t1_count = 0;
int t2_count = 0;
// does this string match with mult-contains
bool t1_match = true;
bool t2_match = true;
char new_filter[MAX_MULTI_CONTAINS_FILTER_SIZE];
strncpy(new_filter, filter, sizeof(new_filter));
new_filter[sizeof(new_filter) - 1] = '\0';
char* token;
char* rest = new_filter;
while((token = strtok_r(rest, " ", &rest))) {
char* str1, *str2;
if(insensitive) {
str1 = strcasestr(text1, token);
str2 = strcasestr(text2, token);
} else {
str1 = strstr(text1, token);
str2 = strstr(text2, token);
}
t1_match = t1_match && str1 != NULL;
t2_match = t2_match && str2 != NULL;
if(str1 != NULL) {
int pos1 = str1 - text1;
t1_count += pos1;
}
if(str2 != NULL) {
int pos2 = str2 - text2;
t2_count += pos2;
}
}
if(t1_match && t2_match) {
// both match
// return the one with the smallest count.
return t1_count - t2_count;
} else if(t1_match) {
return -1;
} else if(t2_match) {
return 1;
} else {
return 0;
}
}
static int contains_sort(const char* text1, const char* text2, const char* filter, bool insensitive) {
char* str1, *str2;
if(insensitive) {
str1 = strcasestr(text1, filter);
str2 = strcasestr(text2, filter);
} else {
str1 = strstr(text1, filter);
str2 = strstr(text2, filter);
}
bool tx1 = str1 == text1;
bool tx2 = str2 == text2;
bool txc1 = str1 != NULL;
bool txc2 = str2 != NULL;
if(tx1 && tx2) {
return 0;
} else if(tx1) {
return -1;
} else if(tx2) {
return 1;
} else if(txc1 && txc2) {
return 0;
} else if(txc1) {
return -1;
} else if(txc2) {
return 1;
} else {
return 0;
}
}
int sort_for_matching_mode(const char* text1, const char* text2, int fallback,
enum matching_mode match_type, const char* filter, bool insensitive) {
int primary = 0;
switch(match_type) {
case MATCHING_MODE_MULTI_CONTAINS:
primary = multi_contains_sort(text1, text2, filter, insensitive);
break;
case MATCHING_MODE_CONTAINS:
primary = contains_sort(text1, text2, filter, insensitive);
break;
case MATCHING_MODE_FUZZY:
primary = fuzzy_sort(text1, text2, filter, insensitive);
break;
default:
return 0;
}
if(primary == 0) {
return fallback;
}
return primary;
}
// end sorting

View File

@ -1,60 +0,0 @@
/*
* Copyright (C) 2019-2020 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#include <property_box.h>
#include <map.h>
struct _WofiPropertyBox {
GtkBox super;
};
typedef struct {
struct map* properties;
} WofiPropertyBoxPrivate;
G_DEFINE_TYPE_WITH_PRIVATE(WofiPropertyBox, wofi_property_box, GTK_TYPE_BOX)
static void wofi_property_box_init(WofiPropertyBox* box) {
WofiPropertyBoxPrivate* this = wofi_property_box_get_instance_private(box);
this->properties = map_init();
}
static void finalize(GObject* obj) {
WofiPropertyBoxPrivate* this = wofi_property_box_get_instance_private(WOFI_PROPERTY_BOX(obj));
map_free(this->properties);
G_OBJECT_CLASS(wofi_property_box_parent_class)->finalize(obj);
}
static void wofi_property_box_class_init(WofiPropertyBoxClass* class) {
GObjectClass* g_class = G_OBJECT_CLASS(class);
g_class->finalize = finalize;
}
GtkWidget* wofi_property_box_new(GtkOrientation orientation, gint spacing) {
return g_object_new(WOFI_TYPE_PROPERTY_BOX, "orientation", orientation, "spacing", spacing, NULL);
}
void wofi_property_box_add_property(WofiPropertyBox* box, const gchar* key, gchar* value) {
WofiPropertyBoxPrivate* this = wofi_property_box_get_instance_private(box);
map_put(this->properties, key, value);
}
const gchar* wofi_property_box_get_property(WofiPropertyBox* box, const gchar* key) {
WofiPropertyBoxPrivate* this = wofi_property_box_get_instance_private(box);
return map_get(this->properties, key);
}

View File

@ -1,119 +0,0 @@
/*
* Copyright (C) 2019-2020 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#include <utils.h>
#include <libgen.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/time.h>
time_t utils_get_time_millis(void) {
struct timeval time;
gettimeofday(&time, NULL);
return (time.tv_sec * 1000) + (time.tv_usec / 1000);
}
void utils_sleep_millis(time_t millis) {
struct timespec time;
time.tv_sec = millis / 1000;
time.tv_nsec = (millis % 1000) * pow(1000, 2);
nanosleep(&time, NULL);
}
char* utils_concat(size_t arg_count, ...) {
va_list args;
va_start(args, arg_count);
size_t buf_s = 1;
for(size_t count = 0; count < arg_count; ++count) {
buf_s += strlen(va_arg(args, char*));
}
va_end(args);
va_start(args, arg_count);
char* buffer = malloc(buf_s);
strcpy(buffer, va_arg(args, char*));
for(size_t count = 0; count < arg_count - 1; ++count) {
strcat(buffer, va_arg(args, char*));
}
va_end(args);
return buffer;
}
size_t utils_min(size_t n1, size_t n2) {
return n1 < n2 ? n1 : n2;
}
size_t utils_max(size_t n1, size_t n2) {
return n1 > n2 ? n1 : n2;
}
size_t utils_min3(size_t n1, size_t n2, size_t n3) {
if(n1 < n2 && n1 < n3) {
return n1;
} else if(n2 < n1 && n2 < n3) {
return n2;
} else {
return n3;
}
}
size_t utils_distance(const char* haystack, const char* needle) {
size_t str1_len = strlen(haystack);
size_t str2_len = strlen(needle);
size_t arr[str1_len + 1][str2_len + 1];
arr[0][0] = 0;
for(size_t count = 1; count <= str1_len; ++count) {
arr[count][0] = count;
}
for(size_t count = 1; count <= str2_len; ++count) {
arr[0][count] = count;
}
uint8_t cost;
for(size_t c1 = 1; c1 <= str1_len; ++c1) {
for(size_t c2 = 1; c2 <= str2_len; ++c2) {
if(haystack[c1 - 1] == needle[c2 - 1]) {
cost = 0;
} else {
cost = 1;
}
arr[c1][c2] = utils_min3(arr[c1 - 1][c2] + 1, arr[c1][c2 - 1] + 1, arr[c1 - 1][c2 - 1] + cost);
}
}
if(strstr(haystack, needle) != NULL) {
arr[str1_len][str2_len] -= str2_len;
}
return arr[str1_len][str2_len];
}
void utils_mkdir(char* path, mode_t mode) {
if(access(path, F_OK) != 0) {
char* tmp = strdup(path);
utils_mkdir(dirname(tmp), mode);
mkdir(path, mode);
free(tmp);
}
}

View File

@ -1,80 +0,0 @@
/*
* Copyright (C) 2020 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#include <utils_g.h>
#include <wofi_api.h>
GdkPixbuf* utils_g_resize_pixbuf(GdkPixbuf* pixbuf, uint64_t image_size, GdkInterpType interp) {
int width = gdk_pixbuf_get_width(pixbuf);
int height = gdk_pixbuf_get_height(pixbuf);
if(height > width) {
float percent = (float) image_size / height;
GdkPixbuf* tmp = gdk_pixbuf_scale_simple(pixbuf, width * percent, image_size, interp);
g_object_unref(pixbuf);
return tmp;
} else {
float percent = (float) image_size / width;
GdkPixbuf* tmp = gdk_pixbuf_scale_simple(pixbuf, image_size, height * percent, interp);
g_object_unref(pixbuf);
return tmp;
}
}
GdkPixbuf* utils_g_pixbuf_from_base64(char* base64) {
char* str = strdup(base64);
char* original_str = str;
if(strncmp(str, "data:", sizeof("data:") - 1) == 0) {
str += sizeof("data:") - 1;
}
GError* err = NULL;
GdkPixbufLoader* loader;
if(strncmp(str, "image/", sizeof("image/") - 1) == 0) {
char* mime = strchr(str, ';');
*mime = 0;
loader = gdk_pixbuf_loader_new_with_mime_type(str, &err);
if(err != NULL) {
goto fail;
}
str = mime + 1;
str = strchr(str, ',') + 1;
} else {
loader = gdk_pixbuf_loader_new();
}
gsize data_l;
guchar* data = g_base64_decode(str, &data_l);
gdk_pixbuf_loader_write(loader, data, data_l, &err);
if(err != NULL) {
g_free(data);
goto fail;
}
g_free(data);
free(original_str);
return gdk_pixbuf_loader_get_pixbuf(loader);
fail:
free(str);
fprintf(stderr, "Error loading base64 %s\n", err->message);
return NULL;
}

View File

@ -1,148 +0,0 @@
/*
* Copyright (C) 2020-2022 Scoopta
* This file is part of Wofi
* Wofi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wofi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wofi. If not, see <http://www.gnu.org/licenses/>.
*/
#include <widget_builder.h>
#include <wofi.h>
#include <utils.h>
struct widget_builder* wofi_widget_builder_init(struct mode* mode, size_t actions) {
struct widget_builder* builder = calloc(actions, sizeof(struct widget_builder));
for(size_t count = 0; count < actions; ++count) {
builder[count].mode = mode;
builder[count].box = WOFI_PROPERTY_BOX(wofi_property_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
if(count == 0) {
builder->actions = actions;
}
}
return builder;
}
void wofi_widget_builder_set_search_text(struct widget_builder* builder, char* search_text) {
wofi_property_box_add_property(builder->box, "filter", search_text);
}
void wofi_widget_builder_set_action(struct widget_builder* builder, char* action) {
wofi_property_box_add_property(builder->box, "action", action);
}
static void va_to_list(struct wl_list* classes, va_list args) {
char* arg;
while((arg = va_arg(args, char*)) != NULL) {
struct css_class* class = malloc(sizeof(struct css_class));
class->class = arg;
wl_list_insert(classes, &class->link);
}
}
void wofi_widget_builder_insert_text(struct widget_builder* builder, const char* text, ...) {
struct wl_list classes;
wl_list_init(&classes);
va_list args;
va_start(args, text);
va_to_list(&classes, args);
va_end(args);
wofi_widget_builder_insert_text_with_list(builder, text, &classes);
struct css_class* node, *tmp;
wl_list_for_each_safe(node, tmp, &classes, link) {
free(node);
}
}
void wofi_widget_builder_insert_text_with_list(struct widget_builder* builder, const char* text, struct wl_list* classes) {
GtkWidget* label = gtk_label_new(text);
gtk_container_add(GTK_CONTAINER(builder->box), label);
gtk_widget_set_name(label, "text");
GtkStyleContext* ctx = gtk_widget_get_style_context(label);
struct css_class* node;
wl_list_for_each(node, classes, link) {
char* tmp = utils_concat(3, builder->mode->name, "-", node->class);
gtk_style_context_add_class(ctx, tmp);
free(tmp);
}
}
void wofi_widget_builder_insert_image(struct widget_builder* builder, GdkPixbuf* pixbuf, ...) {
struct wl_list classes;
wl_list_init(&classes);
va_list args;
va_start(args, pixbuf);
va_to_list(&classes, args);
va_end(args);
wofi_widget_builder_insert_image_with_list(builder, pixbuf, &classes);
struct css_class* node, *tmp;
wl_list_for_each_safe(node, tmp, &classes, link) {
free(node);
}
}
void wofi_widget_builder_insert_image_with_list(struct widget_builder* builder, GdkPixbuf* pixbuf, struct wl_list* classes) {
GtkWidget* img = gtk_image_new();
cairo_surface_t* surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, wofi_get_window_scale(), gtk_widget_get_window(img));
gtk_image_set_from_surface(GTK_IMAGE(img), surface);
cairo_surface_destroy(surface);
gtk_container_add(GTK_CONTAINER(builder->box), img);
gtk_widget_set_name(img, "img");
GtkStyleContext* ctx = gtk_widget_get_style_context(img);
struct css_class* node;
wl_list_for_each(node, classes, link) {
char* tmp = utils_concat(3, builder->mode->name, "-", node->class);
gtk_style_context_add_class(ctx, tmp);
free(tmp);
}
}
struct widget_builder* wofi_widget_builder_get_idx(struct widget_builder* builder, size_t idx) {
return builder + idx;
}
struct widget* wofi_widget_builder_get_widget(struct widget_builder* builder) {
if(builder->actions == 0) {
fprintf(stderr, "%s: This is not the 0 index of the widget_builder array\n", builder->mode->name);
return NULL;
}
if(builder->widget == NULL) {
builder->widget = malloc(sizeof(struct widget));
builder->widget->builder = builder;
builder->widget->action_count = builder->actions;
}
for(size_t count = 0; count < builder->actions; ++count) {
}
return builder->widget;
}
void wofi_widget_builder_free(struct widget_builder* builder) {
if(builder->widget != NULL) {
free(builder->widget);
}
free(builder);
}

File diff suppressed because it is too large Load Diff