Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i3-dmenu-launcher breaks on some desktop applications #5824

Open
hyunlee1o opened this issue Dec 17, 2023 · 4 comments
Open

i3-dmenu-launcher breaks on some desktop applications #5824

hyunlee1o opened this issue Dec 17, 2023 · 4 comments

Comments

@hyunlee1o
Copy link

hyunlee1o commented Dec 17, 2023

I'm submitting a…

[x] Bug
[ ] Feature Request
[ ] Documentation Request
[ ] Other (Please describe in detail)

Current Behavior

When i launch Discord through dmenu through i3-dmenu-desktop it breaks the launch of discord.
Command: i3-dmenu-desktop --dmenu 'rofi -modi window#drun#run#ssh -show drun -sidebar-mode'

2023-12-17 23-20-54_x265

i3-dmenu-desktop log
File /usr/share/applications/qemu.desktop is broken: it contains Type=Application, but no Exec key/value pair. at /usr/local/bin/i3-dmenu-desktop line 256.
File /usr/share/applications/org.freedesktop.Xwayland.desktop is broken: it contains Type=Application, but no Exec key/value pair. at /usr/local/bin/i3-dmenu-desktop line 256.
[{"success":true}]
Uncaught exception:
 Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writeGeneric (node:internal/stream_base_commons:151:3)
    at Socket._writeGeneric (node:net:874:11)
    at Socket._write (node:net:886:8)
    at writeOrBuffer (node:internal/streams/writable:391:12)
    at _write (node:internal/streams/writable:332:10)
    at Writable.write (node:internal/streams/writable:336:10)
    at console.value (node:internal/console/constructor:299:16)
    at console.log (node:internal/console/constructor:376:26)
    at console.log (/usr/share/discord/resources/app.asar/node_modules/@sentry/utils/cjs/instrument.js:124:20)

Expected Behavior

When i run rofi -modi window#drun#run#ssh -show drun -sidebar-mode it works as expected.
Discord launches without issue.

Reproduction Instructions

  1. Install discord for linux
  2. Install rofi
  3. Run i3-dmenu-desktop --dmenu 'rofi -modi drun -show drun'
  4. Type discord and press enter

Environment

Output of i3 --moreversion 2>&-:

Binary i3 version:  4.23-7-g69f68dcd © 2009 Michael Stapelberg and contributors
Running i3 version: 4.23-7-g69f68dcd (pid 4874)
Loaded i3 config:
  /home/user/.i3/config (main) (last modified: lun 27 nov 2023 03:08:30, 1801173 seconds ago)

The i3 binary you just called: /usr/local/bin/i3
The i3 binary you are running: i3-with-al/bin/i3
Config file
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#

i3 config file (v4)

Please see http://i3wm.org/docs/userguide.html for a complete reference!

set $mod Mod4

Font for window titles. Will also be used by the bar unless a different font

is used in the bar {} block below.

This font is widely installed, provides lots of unicode glyphs, right-to-left

text rendering and scalability on retina/hidpi displays (thanks to pango).

font pango:monospace 11

Before i3 v4.8, we used to recommend this one as the default:

font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1

The font above is very space-efficient, that is, it looks good, sharp and

clear in small sizes. However, its unicode glyph coverage is limited, the old

X core fonts rendering does not support right-to-left and this being a bitmap

font, it doesn’t scale on retina/hidpi displays.

Use Mouse+$mod to drag floating windows to their wanted position

exec setxkbmap -option ctrl:swapcaps # Swap Left Control and Caps Lock

popup_during_fullscreen smart
workspace_auto_back_and_forth no
workspace_layout tabbed
hide_edge_borders smart

for_window [title="qmmp*"] move workspace m

set $right_monitor HDMI-A-0
set $left_monitor HDMI-A-1
set $music_player "Clementine"

workspace m output $left_monitor #right
workspace p output $right_monitor #right
workspace w output $left_monitor #right
workspace ed output $right_monitor #left
workspace tg output $left_monitor #right
workspace t output $left_monitor #right
workspace gc output $right_monitor #right
workspace g output $right_monitor #right

use xprop

assign [class="(?i)firefox$"] → p
assign [title="Firefox"] → p
assign [class="(?i)google-chrome*"] → gc
assign [class="^Emacs$"] → ed
assign [class="^Telegram$"] → tg
assign [class="^Clementine$"] → m
assign [class="^(?i)steam$"] → g
assign [class="^Lutris$"] → g
assign [class="TelegramDesktop"] → tg

exec --no-startup-id redshift
exec --no-startup-id qbittorrent
exec --no-startup-id udiskie -tn #sudo apt install udiskie
exec --no-startup-id flameshot #sudo apt install flameshot

exec --no-startup-id workrave #sudo apt install workrave

exec --no-startup-id indicator-sound-switcher # pip install indicator-sound-switcher

exec --no-startup-id mate-volume-control-status-icon

exec --no-startup-id clementine # sudo apt install clementine
exec --no-startup-id nicotine # sudo apt install nicotine
exec --no-startup-id nm-applet # sudo apt install network-manager-gnome
exec --no-startup-id nmcli radio wifi on # fix bad wifi

exec --no-startup-id i3-msg 'workspace 2; $music_player'

#exec --no-startup-id i3-msg 'workspace 3; exec sleep 60; exec steam'
#exec --no-startup-id i3-msg 'workspace 1'
exec --no-startup-id feh --bg-scale ~/Wallpapers/debian-dark-4096x2160.png #sudo apt install feh
exec --no-startup-id autorandr -c 2horizontal #sudo apt install autorandr

Pulse Audio controls

#bindsym XF86AudioRaiseVolume exec --no-startup-id amixer sset Master 5%+ unmute
#bindsym XF86AudioLowerVolume exec --no-startup-id amixer sset Master 5%- unmute

bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% && pactl set-sink-mute @DEFAULT_SINK@ 0
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% && pactl set-sink-mute @DEFAULT_SINK@ 0
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle # mute sound
bindsym XF86Favorites exec --no-startup-id $music_player

scrot & gimp - root

#bindsym Print exec scrot -e 'mv $f /tmp/ && gimp /tmp/$f'
bindsym Print exec flameshot gui

scrot & gimp - select window or rectangle

#bindsym Mod1+Print exec scrot -s -e 'mv $f /tmp/ && gimp /tmp/$f'

floating_modifier $mod

start a terminal

bindsym $mod+Return exec x-terminal-emulator

kill focused window

bindsym $mod+Shift+q kill
bindsym --release $mod+x exec xkill

start dmenu (a program launcher)

#bindsym $mod+d exec dmenu_run

There also is the (new) i3-dmenu-desktop which only displays applications

shipping a .desktop file. It is a wrapper around dmenu, so you need that

installed.

bindsym $mod+d exec --no-startup-id i3-dmenu-desktop

bindsym $mod+d exec "rofi -modi window,drun,run -show drun -sidebar-mode -terminal termite -color-window '#000000, #000000, #000000' -color-normal '#000000, #b3e774, #000000, #b3e774, #000000' -color-active '#000000, #b3e774, #000000, #b3e774, #000000' -color-urgent '#000000, #b3e774, #000000, #b3e774, #000000'"

bindsym $mod+d exec "i3-dmenu-desktop --dmenu 'rofi -modi window#drun#run#ssh -show drun -sidebar-mode'"

alternatively, you can use the cursor keys:

bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

move focused window

bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+ntilde move right

alternatively, you can use the cursor keys:

bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

split in horizontal orientation

bindsym $mod+h split h

split in vertical orientation

bindsym $mod+v split v

enter fullscreen mode for the focused container

bindsym $mod+f fullscreen

change container layout (stacked, tabbed, toggle split)

bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

toggle tiling / floating

bindsym $mod+Shift+space floating toggle

change focus between tiling / floating windows

bindsym $mod+space focus mode_toggle

focus the parent container

bindsym $mod+a focus parent

focus the child container

#bindsym $mod+d focus child

set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"

switch to workspace

bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10
bindsym $mod+apostrophe exec i3-input -F 'workspace %s' -P 'go to workspace: '

move focused container to workspace

bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10
bindsym $mod+Shift+apostrophe exec i3-input -F 'move container to workspace %s' -P 'move to workspace: '

bindsym Control+$mod+Left workspace prev
bindsym Control+$mod+Right workspace next

bindsym $mod+Shift+greater move workspace to output right
bindsym $mod+Shift+less move workspace to output left

bindsym $mod+l exec ~/.i3/fuzzy_lock.sh

bindsym $mod+l exec /Descargas/dotfiles/scripts/rofi-power "/.i3/fuzzy_lock.sh" # sudo apt install scrot

exec xautolock -detectsleep -time 5 -locker ~/.i3/fuzzy_lock.sh -notify 4 -notifier 'xset dpms force off' &

reload the configuration file

bindsym $mod+Shift+c reload

restart i3 inplace (preserves your layout/session, can be used to upgrade i3)

bindsym $mod+Shift+r restart

exit i3 (logs you out of your X session)

bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"

Make the currently focused window a scratchpad

bindsym $mod+Shift+minus move scratchpad

Show the first scratchpad window

bindsym $mod+minus scratchpad show

focus_follows_mouse no

resize window (you can also use the mouse for that)

mode "resize" {
# These bindings trigger as soon as you enter the resize mode

# Pressing left will shrink the window’s width.
# Pressing right will grow the window’s width.
# Pressing up will shrink the window’s height.
# Pressing down will grow the window’s height.
bindsym j resize shrink width 10 px or 10 ppt
bindsym k resize grow height 10 px or 10 ppt
bindsym l resize shrink height 10 px or 10 ppt
bindsym ntilde resize grow width 10 px or 10 ppt

# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt

# back to normal: Enter or Escape or Mod1+r
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym Mod1+r mode "default"

}

bindsym $mod+r mode "resize"

Start i3bar to display a workspace bar (plus the system information i3status

finds out, if available)

bar {
status_command i3status
position top
tray_output $left_monitor
}

bar {

font pango:mono 11

status_command i3blocks

position top

mode dock

modifier None

}

Logfile URL: https://logs.i3wm.org/logs/6329955084402688.bz2
- Linux Distribution & Version: Debian GNU/Linux trixie/sid x86_64. Kernel: 6.5.0-5-amd64
- Are you using a compositor (e.g., xcompmgr or compton): No
@vbreder
Copy link

vbreder commented Dec 19, 2023

Can you go over to /usr/share/applications and find the .desktop file for Discord (probably "discord.desktop") and provide its contents as well? Thank you!

@hyunlee1o
Copy link
Author

discord.desktop
[Desktop Entry]
Name=Discord
StartupWMClass=discord
Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.
GenericName=Internet Messenger
Exec=/usr/share/discord/Discord
Icon=discord
Type=Application
Categories=Network;InstantMessaging;
Path=/usr/bin

@vbreder
Copy link

vbreder commented Dec 20, 2023

I can repro it.

It appears to me that after removing line Path=/usr/bin from the .desktop file, the command I put in Exec now executes correctly.

I'm not a Perl programmer, so I can't help troubleshoot the script, but I can suggest if you'd like to unblock yourself, using: https://github.com/enkore/j4-dmenu-desktop which is a drop-in replacement.

Although for sure it's also worth fixing the script itself which is shipped with i3.

@Maritims
Copy link

Maritims commented May 20, 2024

I've been looking into this issue and noticed that Discord is in fact launched once the following block is executed. I've been able to reproduce this with Bitwarden aswell which is another Electron-based app.

my ($dmenu_out, $dmenu_in);
my $pid = eval {
    open2($dmenu_out, $dmenu_in, $dmenu_cmd);
} or do {
    print STDERR "$@";
    say STDERR "Running dmenu failed. Is dmenu installed at all? Try running dmenu -v";
    exit 1;
};

It doesn't seem like this supposedly premature execution of the selected application is the intention of the script. I suspect that the combination with rofi -modes drun -show drun could be the cause of this behaviour. The $dmenu_cmd variable contains rofi -dmodes drun -show drun at this point in the script execution.

My theory about why the EPIPE error occurs is that Discord attempts to write something to STDOUT, but is unable to do so due to the inner workings of the open2 function and the $dmenu_out variable not being initialized? I'm not a seasoned perl programmer, so arriving at this conclusion was by process of elimination. Commenting out all code after this block confirmed that Discord is executed once the open2 function is executed, and replacing the $dmenu_out function argument with >&STDOUT, which lets the invoked child process (in this case Discord) write to the parent STDOUT results in Discord starting without the EPIPE error.

What is the pid returned by this eval block expected to represent? And surely the selected application isn't supposed to be executed by anything other than the system function call to i3-msg?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants